Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Execute a SQL string and return a value
Message
De
27/03/2001 06:07:04
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
How to Execute a SQL string and return a value
Divers
Thread ID:
00488884
Message ID:
00488884
Vues:
40
I am trying to execute a SQL string, and return a value to a stored procedure. For example

Say I wanted to read @value from the calculation

'set @value= 3 + 2 '

I could use an EXEC statement to calculate the value, the statement however complains that @ value is not specified so it is specified within the sql string.

exec( 'declare @value as int set @value= 3+2 ')

The problem then is that the scope of @value is only within the SQL string. Therefore I cannot read @value.

I have also tried declaring @value from outside of the SQL string, but Query analyser complains about the syntax.

declare @value as int
exec( 'select ' @value ' = 3+2 ')

I realise that i could create a SQL command to write into a temporary table, but it feels like there should be some way to retrieve @Value.

PS. 3+2 is only an example.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform