Painting Blue Code
Simple, self-explanatory code snippets.
2019-07-02
TSQL - Pass the result of executed dynamic SQL to a variable
DECLARE @sql nvarchar(max);
declare @result int;
SET @sql = 'SELECT @x = COUNT(*) FROM SCHEMA_NAME.TABLE_NAME;';
EXECUTE sp_executesql @sql, N'@cnt int OUTPUT', @x=@result OUTPUT;
print @result;
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment