1.SQL
/* 人员:LDH 功能:SQL-sp_executesql介绍和使用 日期:2018-8-15 */ USE TestDB; GO DECLARE @sql NVARCHAR(2000); DECLARE @cou INT; DECLARE @id INT; SET @id = 1; SET @sql = 'SELECT @count=COUNT(1) FROM Person WHERE Id = @id'; EXEC sp_executesql @sql, N'@count int out,@id int', @cou OUT, @id; PRINT @cou;
2.运行结果
转载于:https://www.cnblogs.com/LifeDecidesHappiness/p/9479631.html