views:

1142

answers:

6

Hi

In SQL Server, what is the difference between the following two-

  • Right click on a database object (table/view) and opt for Drop table (i.e. Script table as -> DROP To -> New Query Editor Window)

  • Right click on a database object (table/view) and opt for Delete.

I tried them both and both perform the same action. Any reason for having two options for the same thing? Is the Delete option just a crude way of dropping the DB object?

Just for the record - I'm using SS2008.

cheers

+2  A: 

One of these performs a delete, the other provides you with the TSQL script to do a delete so you can modify or use it elsewhere.

DamienG
yeah, you're right :) I haven't looked at this in such a way - my answer is more outcome-oriented, and you have noticed that generating DROP statement allows to make some manual changes, or copy to a script, for example... I'm voting for your answer, cheers :)
Michał Chaniewski
A: 

Those two are the same operations. DROP TABLE is SQL statement for this, Delete is standard, user-friendly, menu-driven command name. That's all.

Michał Chaniewski
+2  A: 

it is drop table and delete object, at least in SQL Server 2005. Both perform the same action.

Delete table and Drop table are not the same though. The former will delete all data from the table whilst the latter will remove the table from the database.

Russ Cam
A: 

If you choose Delete, then choose to script it, you will see that it gives you a drop table statement as well.

ShadyRudy
A: 

In the delete object GUI, on top there is a 'script' option which gives the t-sql statement which is plain drop table statement. Where as when you go for the drop table option, the t-sql generated would perform drop only if the table exists in the sys.objects table.

Andriyev
A: 

Drop table..it will delete complete table from th Database.it can not retrieved bak Delete is used to deleting data from the table.. data can be retrieved using ROLLBAck.

meenakshi