SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

sp_truncate

By Sergey Benner, 2009/01/23

Total article views: 1152 | Views in the last 30 days: 21

sp_truncate <table_2_truncate>

I've created this procedure several months ago and I hope it would be helpful.

It truncates the table even those which are referenced by some other tables' foreign keys.

We shall truncate the table test1 which is referenced by e.g. 2 tables (test2,test3)

Then we execute sp_truncate test1 

 

Hope it will save you lots of time like it did for me.

By Sergey Benner, 2009/01/23

Total article views: 1152 | Views in the last 30 days: 21
Your response
 
 
Related Articles
FORUM

Truncate log

Truncate log

SCRIPT

Truncate All Tables

Script to Truncate all tables part1

FORUM

truncate the transactional logfile

truncate the transactional logfile

FORUM

Regarding Transaction file Truncation...!

Regarding Transaction file Truncation...!

FORUM

Truncating Log During Backup

Truncating log during backup

Tags
foreign key    
truncate table    
 
Contribute

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com