sql

SqlDataReader doesn't have third record set

I have a Stored Procedure that returns three record sets. Here it is being called in Studio. EXEC CampaignData '007CF7F8-AE8D-DE11-8BBA-0003FF4C13C9' I can't cut and paste the record sets from Management Studio but trust me it shows three record sets, first one has one row with 2 values, the second has three rows and the third has 2 r...

which datatype i use in sqllite to store this value as same 12/12/2009

I tried hard but couldn't got the answer ...

Use variable with TOP in select statement in SQL Server without making it dynamic

declare @top int set @top = 5 select top @top * from tablename Is it possible? Or any idea for such a logic (i don't want to use dynamic query)? ...

Delete set of duplicate records and Keep another set of duplicate record.

Please see data given below I want to keep one set of records and want to delete another duplicate set of records. You can see ForeignKey are same just Primary Key is different. Need to keep 2 records having lowest primary key among the set of 4 records. ...

How do i get the return value coming a database with just using return?

I need to get the value returned from a stored procedure in my Sql Server db.a This store procedure using a return statement to return a value back to the app. I need to retrieve this value in C#. How do i get this value? Note: I know i can use ExecuteScalar while using "select ..." in the sp to retrieve this value. I also know i can...

Populate DataGridView from a Stored Procedure

Using SQL Server 2008 I created a Stored Procedure called MyStoreProc and it runs fine from the Management Tools. In VB.Net 2008 I created a new dataset and a new TableAdaptor. In this table adapter I created a new Query called FillByGrid and selected the Stored Procedure. Previewed data and it previewed correctly. On a form I create...

SQL select where there is only one date

Currently this query: SELECT InvoiceNumber, CustomerCode, Amount, InvoiceDate FROM Invoice Returns: aaa, 111, 5, 07/12/2009 bbb, 111, 5, 07/11/2009 ccc, 222, 5, 07/12/2009 However, I want to write: Where date = '07/12/2009', but I only want to return the results where there the customer has only one invoice... So Custo...

SQL Server VARCHAR(2) join performance vs. INT

Hi I have a table of q-grams (2 letter strings). I need to join another table to this on the CHAR(2) field. Would it be faster to convert these 2-grams into a number (e.g. aa=1, ab=2, ac=3) and convert the fields in both this table and the referencing table to an INT and join using an INT rather? Kind regards Peter ...

Find a string within the source code (DDL) of a stored procedure in oracle.

Hello, I need to find a string in the source code (DDL) for all stored procedures in Oracle schema. I use this query to perform the task, but I think can be improved SELECT T0.OBJECT_NAME FROM USER_PROCEDURES T0 WHERE T0.OBJECT_TYPE='PROCEDURE' AND INSTR( (SELECT DBMS_METADATA.GET_DDL('PROCEDURE',T0.OBJECT_NAME,'MySCHEMA') ...

select a count of all messages with de date of the latest

Hello I would like to show a list of all messages with the date of the latest message. I've acomplished the list. SELECT COUNT(*) AS NumberOfTimes, TrackRecord.message_identifier, MessagesInstalledApplications.messageKind FROM TrackRecord INNER JOIN MessagesInstalledApplications ON TrackRecord.message_identifier = MessagesInstalledAppli...

TSQL foreign keys on views?

I have a SQL-Server 2008 database and a schema which uses foreign key constraints to enforce referential integrity. Works as intended. Now the user creates views on the original tables to work on subsets of the data only. My problem is that filtering certain datasets in some tables but not in others will violate the foreign key constrain...

Database Job Scheduling

I have a procedure written in PLJava that sends out updates over JMS in my postgres database. What I would like to do is have that function called on an interval (every 15 seconds) internally in the database (preferably not from an outside process). Is this possible? Any ideas? ...

Delete a record and all the record that precede it

I have a table that has a primary key based on GUIDs. I need to find a record in this table based on the primary key and then delete this record and all the record that appear before it. Is there a command to delete preceding records or can anyone give me some example SQL on how I could do this. I am using SLQ server 2008 ...

SQL Insert multiple rows using stored procedure and xml parameter?

I've used a table valued parameter before, but I'm not sure how to use xml. I do not know the best way to format my xml but I think I would try this: <Car> <Name>BMW</Name> <Color>Red</Color> </Car> Then I would pass the xml (one or more car) to the stored procedure and it would insert one row for each car I pass (with ...

Need to assign multiple attributes to records - should I opt for one table or multiple tables?

I am using an MVC pattern to represent a table with many records of music albums. To each music album there are attributes (genre, artist, ratings, etc). Each attribute can have multiple values (so the genre of one album can be both "pop" and "latin", for example). I want to represent those attribute values using table(s). So there are ...

How do I prevent the Entity Framework from escaping my Regex?

Put simply... in plain SQL I would do this: SELECT * FROM [Products] WHERE [Description] LIKE '%[0-9]%' In Linq to Entities I do this: Products.Where(p => p.Description.Contains("[0-9]")) But I end up with this: -- Region Parameters DECLARE @p0 NVarChar(8) SET @p0 = '%~[0-9]%' -- EndRegion SELECT ... FROM [Products] AS [t0] WHERE ...

PHP function to get the date format?

I know how to use date format strings, to turn date('Y/m/d H:i:s'); into 2009/12/18 11:37:45. I would like a function that can do the opposite - look at a formatted date then return the format. Is there one in PHP? The reason is we have timestamps saved in our database in a variety of formats and I am writing a tool processing all of ...

Fine control over SQL Sort Order

I have a SQL Report driven by a query that sorts it in ascending order of some numerical value. But the user wants two particular rows of data, which happen to appear at different ordinal positions in the query results, to be juxtaposed. Is there a way to do this, either through the report's driving SQL or the .rdl file itself? ...

Optimize SQL Query on calculated value?

I have a query that requires a where statement on a calculated value: select * from table where date( timestamp ) = ? An explain on this query yields the expected ALL select type, which is not ideal. Using MySQL, what's the best way to optimize this? ...

SQL Virtual Table

I have my database set up as such: Each product I have has it's own table where it records the quantity sold/transaction # (so column 1 is "transactionID", column 2 is "quantity") ex) p-backScratcher (where p- is indicative of "product") There are also tables for each year which hold records of each transaction that went through. Eac...