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

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

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

>execute (@sql)

Can you not use a stored procedure with parameters (including an output parameter) to access the data you require?

For example

create procedure someprocedure
field varchar(20), table varchar(50), wherecondition varchar(200), myvar varchar(16) OUTPUT
as
select @myvar = @field from @table where @wherecondition

This will return the field required into the myvar variable

Cheers
Steve Lea
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform