动态执行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-13 18:49  rob_2010  阅读(117)  评论(0)    收藏  举报