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
You could use sp_executesql
, like:
declare @sql nvarchar(max);
set @sql = N'select @cnt = count(*) from ' + @tablename;
declare @cnt int;
exec sp_executesql @sql, N'@cnt int output', @cnt = @cnt output;
select @cnt;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With