日期:2014-05-18 浏览次数:20406 次
create PROCEDURE userPC @tableName varchar(100), @condition varchar(250), @RecordCount int output as SET NOCOUNT ON --指示存储过程不返回查询影响的行数 DECLARE @sql NVARCHAR(100) SET @sql = N'SELECT @count=COUNT(*) FROM ' + @tableName + ' WHERE ' + @condition EXEC sp_executesql @sql, N'@count INT OUTPUT', @count=@RecordCount OUTPUT go
------解决方案--------------------
随手敲的,未测试.
DECLARE @sql NVARCHAR(1000),@count INT SET @sql=N'SELECT @count=COUNT(*) FROM ' + @tableName + ' WHERE ' + @condation EXEC sp_executeSQL @sql,N'@count INT OUTPUT',@count OUTPUT
------解决方案--------------------
CREATE PROC procName ( @id INT, @x VARCHAR, @count INT OUTPUT ) AS BEGIN SELECT * FROM tb WHERE id=@id AND v LIKE '%' + @x + '%' SELECT @count=@@ROWCOUNT END