SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Difference bewteen drop and delete
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tkotey
Yak Posting Veteran

75 Posts

Posted - 07/12/2008 :  04:51:48  Show Profile  Reply with Quote
What is the difference between drop table and delete table

madhivanan
Premature Yak Congratulator

India
22772 Posts

Posted - 07/12/2008 :  04:57:54  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 07/12/2008 :  11:17:44  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 07/12/2008 :  14:43:07  Show Profile  Reply with Quote
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

USA
37466 Posts

Posted - 07/12/2008 :  14:47:10  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

India
52325 Posts

Posted - 07/12/2008 :  14:49:46  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 07/12/2008 :  15:09:39  Show Profile  Reply with Quote
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

USA
332 Posts

Posted - 07/12/2008 :  15:17:02  Show Profile  Reply with Quote
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

USA
37466 Posts

Posted - 07/12/2008 :  15:28:05  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

India
52325 Posts

Posted - 07/12/2008 :  15:30:07  Show Profile  Reply with Quote
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

USA
37466 Posts

Posted - 07/12/2008 :  15:40:21  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 07/12/2008 :  16:05:45  Show Profile  Reply with Quote
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

USA
37466 Posts

Posted - 07/12/2008 :  16:20:44  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000