SQL Server中执行Sql字符串,返回执行结果
今天遇到一个问题:想把sql字符串在SQL Server 中执行了,并获取执行的结果
DECLARE @tablename NVARCHAR(300); SET @tablename='select @table3 = count(1) from UserVisitLog'; DECLARE @newtablename NVARCHAR(300); exec sp_executesql @tablename, N'@table3 NVARCHAR(300) OUT',@newtablename OUT PRINT @newtablename