Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple queries in a stored procedure
Message
From
25/01/2002 08:46:34
 
 
To
25/01/2002 02:37:56
Anumala Laxminarayana
Niha Communications Prt.Ltd
Hyderabad, India
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00610320
Message ID:
00610406
Views:
21
First, your use of Dynamic SQL will probably fail. Dynamic SQL is considered a different batch by the execution engine and your local variables will not be in scope. To make it work, you'd have to use the local variable to create a literal within the query:
select  @sql_stat = 'select jeid from jsregistration where username = ' 
SELECT @sql_stat = @sqlstat + '''' + @req_username + ''''
(I broke it into two lines to make the quoting a little clearer. You can do it in one line)

Second. As Sergey mentioned, you really don't have to execute the query to determine the value of the identity that was assigned. Sergey mentioned @@IDENTITY but if you're using SQL Server 2000, I would recommend SCOPE_IDENTITY().

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Reply
Map
View

Click here to load this message in the networking platform