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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-07-16 : 07:27:05
|
| Ambika writes "I am using SQL Server 2000 T-Sql I am not able to code: get the number of rows in a table into a variable where the tablename is a variableThis is my code:declare @counter intdeclare @tablename varchar(100)exec('select @counter=count(*) from ' + @tablename)The above does not work because @counter has not been declared inside the exec() session.The problem is because I cannot hard code @tablenamePlease tell me a way around itThanks-Ambika" |
|
|
smccreadie
Aged Yak Warrior
505 Posts |
Posted - 2003-07-16 : 07:29:53
|
| This question gets asked a lot - see http://www.sqlteam.com/FAQ.asp and click on the dynamic SQL links to learn how to build a query dynamically. |
 |
|
|
|
|
|