Truncate All Tables in sql server database

USE [DatabaseName]
EXEC sp_MSforeachtable 'TRUNCATE TABLE ?'
 
Be careful that this will delete ALL data from all user tables.
In case you are not able to TRUNCATE due to foreign keys etc. you can run the same as a delete:

USE [DatabaseName]
EXEC sp_MSforeachtable 'DELETE FROM ?'

Comments

Popular posts from this blog

SQL Interview Questions and Answers

Generic Interface and Factory Pattern in C#

How to get device info IMEI programmatically in xamarin android