Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiple queries in a stored procedure
Message
De
25/01/2002 08:46:34
 
 
À
25/01/2002 02:37:56
Anumala Laxminarayana
Niha Communications Prt.Ltd
Hyderabad, Inde
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00610320
Message ID:
00610406
Vues:
22
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform