动态执行sql语句并返回值

DECLARE @str nvarchar(50)
DECLARE @icount INT
DECLARE @icnt INT
SET @str = 'select @icount = count(1) from test3'
EXEC sp_executesql @str,N'@icount int out',@icnt OUT
SELECT @icnt AS tt

新建选项卡

posted @ 2010-11-12 16:26  scarbean  阅读(404)  评论(0编辑  收藏  举报