dbTalk Databases Forums  

TRUNCATE TABLE @table_name

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss TRUNCATE TABLE @table_name in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Boogha
 
Posts: n/a

Default TRUNCATE TABLE @table_name - 11-25-2007 , 08:07 PM







I have a cursor looping through a list of tables that I want to
truncate and then do a bulk insert into, Is this possible in SQL
Server 2000 or do script each table individually.

Cheers,
Adam

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: TRUNCATE TABLE @table_name - 11-26-2007 , 02:26 AM






Boogha (boogha (AT) gmail (DOT) com) writes:
Quote:
I have a cursor looping through a list of tables that I want to
truncate and then do a bulk insert into, Is this possible in SQL
Server 2000 or do script each table individually.
Seems like you need to learn dynamic SQL:

EXEC('TRUNCATE TABLE ' + @table)

And while that looks very simple, before you use it all over town, there is
an article on my web site that tries to explain both the benefits and the
pitfalls: http://www.sommarskog.se/dynamic_sql.html.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #3  
Old   
Madhivanan
 
Posts: n/a

Default Re: TRUNCATE TABLE @table_name - 11-26-2007 , 08:12 AM



On Nov 26, 7:07 am, Boogha <boo... (AT) gmail (DOT) com> wrote:
Quote:
I have a cursor looping through a list of tables that I want to
truncate and then do a bulk insert into, Is this possible in SQL
Server 2000 or do script each table individually.

Cheers,
Adam
If you want to truncate all the tables, then try this
http://sqlblogcasts.com/blogs/madhiv...s-part-ii.aspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.