动态执行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
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