Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Truncate All Tables - Part I

Aug 27 2007 9:30AM by Madhivanan   

This procedure will truncate all the tables in the database To truncate all tables,I have seen the programmers using Cursors to get all tables and truncate them.This will avoid Cursors. Running this procedure will make SQL Server to slow down other tasks. So test this with test server and make sure that you are not running any other SQL Server related processes

Create Procedure Truncate_All_Tables
as
Declare @t table(query varchar(1000),tables varchar(50))

Insert into @t 
    select 'Truncate table ['+T.table_name+']', T.Table_Name from 
    INFORMATION_SCHEMA.TABLES T
    left outer join INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
    on T.table_name=TC.table_name     where (TC.constraint_Type ='Foreign Key' or TC.constraint_Type is NULL) and     T.table_name not in ('dtproperties','sysconstraints','syssegments') and     Table_type='BASE TABLE'  

Insert into @t 
    select 'delete table ['+T.table_name+']', T.Table_Name from 
    INFORMATION_SCHEMA.TABLES T
    left outer join INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
    on T.table_name=TC.table_name where TC.constraint_Type ='Primary Key' and     T.table_name <>'dtproperties'and Table_type='BASE TABLE' 

Declare @sql varchar(8000)
Select @sql=IsNull(@sql+' ','')+ query from @t

Exec(@sql)
GO

Run this procedure as

EXEC Truncate_All_Tables

Tags: t-sql, sql_server, truncate_table,


Madhivanan
3 · 40% · 12862
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]