[Solved] I want to insert a record in DB and then need to return a row

One way to do what you want is to modify @voucherNo to be an OUTPUT parameter, and add a new OUTPUT parameter to your query to return the value of SCOPE_IDENTITY(). @voucherNo varchar(max) @ScopeIdentity numeric(38,0) And modify that last SELECT statement to set the value of @ScopeIdentity parameter. SELECT @ScopeIdentity = SCOPE_IDENTITY() Then use SqlCommand.ExecuteNonQuery … Read more

[Solved] . It’s working fine when I pass 10-15 input but taking more than 5 minutes for 30 input. I need to make it work for 100 inputs

. It’s working fine when I pass 10-15 input but taking more than 5 minutes for 30 input. I need to make it work for 100 inputs solved . It’s working fine when I pass 10-15 input but taking more than 5 minutes for 30 input. I need to make it work for 100 inputs

[Solved] Taking lot of time to read from SQL Server using c#

Something like this might work. I’m not sure on the efficiency yet – it may depend on the amount of hits that you’re looking for: create type HitBlocks as table ( HitIndex int not null ) go create procedure FindMaxCover @Hits HitBlocks readonly as ;With DecomposedBlocks as ( select (HitIndex/8)+1 as ByteIndex,POWER(2,(HitIndex%8)) as BitMask from … Read more

[Solved] Unable to Subtract Dates SQL Server

I see from your post edit last time, value from field datetime like ’20/Mar/2013:03:17:44′. Format from value of datetime can’t convert by a simple way. Try this query: SELECT BASESCORE, [DATEDIFF]= Datediff(second, Min(CONVERT(DATETIME, LEFT(Rtrim(Ltrim(DATETIME)), 11) + ‘ ‘ + RIGHT(Rtrim(Ltrim(DATETIME) ), 8))), Max ( CONVERT(DATETIME, LEFT(Rtrim(Ltrim(DATETIME)), 11 ) + ‘ ‘ + RIGHT(Rtrim(Ltrim(DATETIME)), 8)))) FROM … Read more

[Solved] Identity Increment [closed]

First, you should know that you are doing a cartesian product of your tables. If you want to add an identity column when you are creating your table, then do the following: Select IDENTITY(INT,1,1) ID, Calls.*,Patient.* INTO Calls2 From Calls,Patient solved Identity Increment [closed]

[Solved] Duplicates of multiple values selected only by one Name: comma separated

Create your table taro: SELECT * INTO taro FROM ( SELECT 1111 AS [C no.], ‘ken’ AS [Name], ‘shiro’ AS Item, ‘3/3/2000 12:22’ AS [Date], ‘$25’ AS Amount UNION ALL SELECT 1111 AS [C no.], ‘ken’ AS Name, ‘aeshte’ AS Item, ‘3/3/2000 12:22’ AS [Date], ‘$25’ AS Amount UNION ALL SELECT 1111 AS [C no.], … Read more

[Solved] syntax error while executing sql [closed]

Try this, you are missing “+”s and “‘”s: DECLARE @SQL NVARCHAR(MAX) = N’ SELECT CASE WHEN ISNULL(10, ””) = ”” AND ISNULL(””, ””) = ”” THEN ”” ELSE CONVERT(NVARCHAR(5), 10) + ‘ + ”’ To ”’ + ‘ + CONVERT(NVARCHAR(5), 20) END;’; SELECT @SQL; EXEC(@SQL); 1 solved syntax error while executing sql [closed]