Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get var back from dynamic SQL
Message
De
06/01/2000 10:56:19
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
How to get var back from dynamic SQL
Divers
Thread ID:
00313925
Message ID:
00313925
Vues:
73
Hi,

I have code like

------------------------------
declare @sql varchar(128), @myvar varchar(16)

set @sql = 'declare @myvar varchar(16) select @myvar = somefield from sometable where wherecondition'

execute (@sql)


select @myvar
-------------------------

Now - the 'inside' @myvar is NOT available to the 'outside' program! How can I get it from the dynamic sQL statement? or can I?

I also notes that if the 'inside' statement selects into a #temp table, that #temp table is NOT available to the outside statement - putting it to a ##temp table DOES work, but this seems to go against the documentation that says a #temp table is available to the ENTIRE CONNECTION - not just batch/task. PLus ##temp tables are avaialble to ALL connections (according to docs) and I certainly don't want that.

Thanks!
Ken B. Matson
GCom2 Solutions
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform