Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
senthilramtrs
Starting Member
29 Posts |
Posted - 2008-05-15 : 04:11:44
|
tell me how to get no of records in a table whose table name is given as input to the stored procedure....i have set a @NOR as output create procedure retrieve_no_rows @tablename varchar(20), @NOR int outputasDECLARE @sSQL VARCHAR(200)SET @sSQL = 'select count(*) from ' + @tablenameSet @NOR = EXEC @sSQL // error on this linegoRegards,Senthil Ram TRS |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-15 : 04:16:56
|
This has been asked a few times last month.Please search SQLTeam for answer.Relevant keywords are:DYNAMIC SQL, sp_executesql, totalt number of records in table E 12°55'05.25"N 56°04'39.16" |
 |
|
senthilramtrs
Starting Member
29 Posts |
Posted - 2008-05-15 : 04:43:44
|
quote: Originally posted by Peso This has been asked a few times last month.Please search SQLTeam for answer.Relevant keywords are:DYNAMIC SQL, sp_executesql, totalt number of records in table E 12°55'05.25"N 56°04'39.16"
can u make changes in my code or tell me sme new idea/code plsRegards,Senthil Ram TRS |
 |
|
manishm2278
Starting Member
1 Post |
Posted - 2008-05-15 : 08:08:42
|
declare @tablename varchar(100)DECLARE @sSQL nVARCHAR(200)set @tablename = 'tblServiceAccts'SET @sSQL = 'select count(*) NOR from ' + '' + @tablename + ''exec sp_executesql @sSQL |
 |
|
|
|
|