How to do any activity like select, delete or truncate for all tables in a databases?

Use databasename

Go
sp_tables


Filter the above query output by TABLE_TYPE AS TABLE.

Then copy all table_name column values from the results in SSMS and paste it in the excel sheet columns.

Then join table_name with below statements in another excel column.

Lets take how to truncate all tables in a database.


="TRUNCATE TABLE ” &A1 &" "


Employeesdetails
TRUNCATE TABLE  Employeesdetails


Any other method to do the above activity.

Comments

Popular posts from this blog

SSIS2008R2 Error: 0xC0209303 at Package:

SQL2008R2 Error: The remote copy of database "XXXXX" has not been rolled forward to a point in time that is encompassed in the local copy of the database log. (Microsoft SQL Server, Error: 1412)