Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with variable in Execute
Message
De
17/09/2001 05:20:57
Martin Van Krieken
Capgemini Nederland Bv
Utrecht, Pays-Bas
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00556400
Message ID:
00557208
Vues:
18
Thanks Sergey, Your solution works great.

Martin

>Hi Martin,
>
>Dynamic SQL runs in its own context not in the context of SP that executed it. Because of that SP variables are not within scope of Dynamic SQL. The common practice is to store a return value to a temporary table and than use it in the calling SP.
>
>Create Procedure sp_GetData
>(
>@tcWhere VarChar(100),
>@tcReturn VarChar(1000) Output
>)
>As
>Declare @lcSql VarChar(1000)
>CREATE TABLE #returnvalue ( cReturn VarChar(1000) )
>Set @lcSql = 'Select cField From Table where ' + @tcWhere
>INSERT INTO #returnvalue Exec (@lcSql)
>SET @tcReturn = (SELECT cReturn FROM #returnvalue )
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform