Thursday, July 23, 2009

Truncate all the table in a DB (MS-Sql 2000 & MS-Sql 2005)

Ms-Sql 2000

declare @SQL varchar(8000)

set @SQL = ''

select @SQL = @SQL + ' truncate table ' + name from sysobjects where type = 'U' and name <> 'dtproperties'

exec(@SQL)

Ms-Sql 2005

Exec sp_MsForEachTable 'TRUNCATE TABLE ?'

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.