Hi everyone,
Im trying to do the following code for a simple test on variable (not working but the logic show what i want to get).
Im trying to get informations from an exec/sp_executesql command using a variable declared before the command and use that extracted value in another query later. Am i far from the solution?
Code Snippet
DECLARE @.i int
DECLARE @.sql nvarchar(4000)
SELECT @.sql = 'SELECT @.i = Count(*) from tblTableTest'
exec sp_executesql @.sql
PRINT @.i
You have to declare the list of parameters.
Code Snippet
DECLARE @.i int
DECLARE @.sql nvarchar(4000)
SELECT @.sql = 'SELECT @.i = Count(*) from tblTableTest'
exec sp_executesql @.sql, N'@.i int output', @.i output
PRINT @.i
AMB
No comments:
Post a Comment