Click here to Skip to main content
15,898,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CREATE PROCEDURE [dbo].[TableRowCount]
	@tableName text,
	@count int OUTPUT
AS
	EXEC('SELECT * FROM ' + @tableName)
	SET @count = @@ROWCOUNT
RETURN @count
Posted
Comments
[no name] 14-May-14 20:44pm    
You are probably going to have to explain what you mean. Just dumping some code is not a question or description of a problem.
Olanrewaju Joseph 15-May-14 4:15am    
I want to pass the table name as parameter to the stored procedure and get the number of rows as the output.

Why not just simply
SQL
SELECT COUNT(TableName.TablePK) FROM TableName
-- Because SELECT * is a really bad habit

?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900