Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Difference bewteen drop and delete

Author  Topic 

tkotey
Yak Posting Veteran

75 Posts

Posted - 2008-07-12 : 04:51:48
What is the difference between drop table and delete table

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-12 : 04:57:54
quote:
Originally posted by tkotey

What is the difference between drop table and delete table


Did you see the information in sql server help file?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-12 : 11:17:44
quote:
Originally posted by tkotey

What is the difference between drop table will drop whole table and delete table will only delete data
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-12 : 14:43:07
drop table is DDL statement which drops the table itself while delete table keeps the table and removes only the data and hence is DML.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-12 : 14:47:10
There is no DELETE TABLE statement in SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-12 : 14:49:46
quote:
Originally posted by tkizer

There is no DELETE TABLE statement in SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



sorry my bad. i meant DELETE FROM Table
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-12 : 15:09:39
quote:
Originally posted by tkizer

There is no DELETE TABLE statement in SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog





you can use DELETE TABLE(TABLENAME)
Go to Top of Page

laddu
Constraint Violating Yak Guru

332 Posts

Posted - 2008-07-12 : 15:17:02
quote:
Originally posted by tkotey

What is the difference between drop table and delete table


DELETE TABLE cmd removes the rows from a table based on the condition that we provide with a WHERE clause.DELETE TABLE can be rolled back.

DROP TABLE cmd drops the total table
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-12 : 15:28:05
quote:
Originally posted by sodeep

quote:
Originally posted by tkizer

There is no DELETE TABLE statement in SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog





you can use DELETE TABLE(TABLENAME)



No you can't, so prove it. BOL doesn't give any indication of this either.

Here's my test:

SQL Server 2000:
create table table1 (col1 int)

delete table (table1)

Error:
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'table'.

SQL Server 2005:
create table table1 (col1 int)

delete table (table1)

Error:
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'table'.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-12 : 15:30:07
quote:
Originally posted by tkizer

quote:
Originally posted by sodeep

quote:
Originally posted by tkizer

There is no DELETE TABLE statement in SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog





you can use DELETE TABLE(TABLENAME)



No you can't, so prove it. BOL doesn't give any indication of this either.

Here's my test:

SQL Server 2000:
create table table1 (col1 int)

delete table (table1)

Error:
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'table'.

SQL Server 2005:
create table table1 (col1 int)

delete table (table1)

Error:
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'table'.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



But you can use DELETE table1.just realised FROM is optional

http://doc.ddart.net/mssql/sql70/de-dz_5.htm
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-12 : 15:40:21
Yes but that's not DELETE TABLE.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-12 : 16:05:45
quote:
Originally posted by tkizer

quote:
Originally posted by sodeep

quote:
Originally posted by tkizer

There is no DELETE TABLE statement in SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog





you can use DELETE TABLE(TABLENAME)



No you can't, so prove it. BOL doesn't give any indication of this either.

Here's my test:

SQL Server 2000:
create table table1 (col1 int)

delete table (table1)

Error:
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'table'.

SQL Server 2005:
create table table1 (col1 int)

delete table (table1)

Error:
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'table'.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog




What I meant was exactly what visakh said. And how can we use DELETE Table tablename since delete doesn't touch structure of table which has already been stated.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-12 : 16:20:44
I've never said anything about structure. My whole point is that DELETE TABLE is not a valid T-SQL command. Please re-read all of my posts in this thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -