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 |
|
psystems
Starting Member
8 Posts |
Posted - 2005-08-08 : 16:35:51
|
| Hi,I have a temp table containing 3 fields:table name, record count 1, record count 2.I want to loop thru this temp table and if record count 1 = record count 2 then I want to TRUNCATE TABLE tablename . How can I do this without having a truncate statement for every table name?Thanks, |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-08-08 : 16:48:48
|
| you'll have to build a dynamic sql to generate the command to truncate the different tables.I'm sure there are examples of writing dynamic sql on the main sqlteam page if you are not familiar with how to do this.-ec |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-09 : 01:46:00
|
| Run thisSelect 'Truncate Table '+tablename from temptable where recordcount1=recordcount2Copy the result and paste in QA and runMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|