Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

Assign value to variable inside Dynamic SQL

DECLARE @result INT
       ,@query NVARCHAR(MAX);

SET @query = '
  SET @result= 1';

EXEC sp_executesql @query, N'@result INT OUTPUT',@result =  @result OUTPUT

SELECT @result;
 
PREVIOUS NEXT
Tagged: #Assign #variable #Dynamic #SQL
ADD COMMENT
Topic
Name
3+8 =