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 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2010-08-12 : 13:30:23
|
| Hi thereI have a table that contains a list of staging tables names. staging tables could be added replace, removed etc. The process I have needs to truncate these staging tables. How can I do so in one take instead of looping through the metadata tables?ThanksIf you don't have the passion to help people, you have no passion |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-08-12 : 13:42:53
|
| declare @sql varchar(max)select @sql=isnull(@sql,'') + replace('TRUNCATE TABLE [ ! ]','[ ! ]',table_name) +' 'from information_schema.tables where table_name --like 'staging%'EXEC ( @sql)JimEveryday I learn something that somebody else already knew |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2010-08-12 : 13:51:42
|
| gorgeous!Thanks a lot Jim!If you don't have the passion to help people, you have no passion |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-08-12 : 14:10:35
|
| You're welcome!Everyday I learn something that somebody else already knew |
 |
|
|
|
|
|