【发布时间】:2012-09-05 13:49:54
【问题描述】:
create procedure qa_cc
@tablename varchar(500)
AS
BEGIN
-- Create two integer values
DECLARE @tableOneCount varchar(50), @tableTwoCount varchar(50)
-- Get the number of rows from the first table
SELECT @tableOneCount = 'SELECT COUNT(*) FROM' + @tablename;
exec (@tableOneCount);
select @tableOneCount ;
END
exec qa_cc @tablename=table1
【问题讨论】:
-
那里有问题吗?
-
显而易见的问题是如何让它工作。在示例查询中,
@tableOneCount在exec期间超出范围。对新用户友好一点也无妨!
标签: sql sql-server tsql count row