Sunday, March 8, 2015

SQL Server Brain Basher of the Week #002

Here is the Brain Basher of this week. As you know, if you have multiple objects to be deleted, for an example, 3 tables, we write three statements as below.

DROP TABLE dbo.T1;
DROP TABLE dbo.T2;
DROP TABLE dbo.T3;

Can we write one statement or one command to do this?

Yes, it is possible, as long as they are similar type of objects. All we have to do is, have the command with object names separated with comma. Here is an example.

DROP TABLE dbo.T1, dbo.T2, dbo.T3;

Have a good week ahead!


No comments:

Post a Comment