Monday, June 30, 2014

Truncate all table from a database in sql server

declare @tblname VARCHAR(255)
declare tbl_cursor cursor for
select name from sys.tables
open tbl_cursor
fetch next from tbl_cursor into @tblname
while @@FETCH_STATUS = 0
begin
     print  @tblname
    --EXECUTE ('truncate table '+ @tblname)
    fetch next from tbl_cursor into @tblname
end
close tbl_cursor
deallocate tbl_cursor

No comments:

Post a Comment

Opps Part 1 : Abstraction

  Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...