Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
T-SQL (SS2K8)
»
Something fissy about DELETE
Something fissy about DELETE
Rate Topic
Display Mode
Topic Options
Author
Message
Shadab Shah
Shadab Shah
Posted Sunday, December 23, 2012 7:48 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 2:11 PM
Points: 169,
Visits: 355
I create a table as
CREATE TABLE DEMO (A INT)
Then i deleted it as follow
DELETE DEMO
I tried to again recreate the table using the same above statement, But it gave me the following error message
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'DEMO' in the database.
Now over here i am trying to understand when i deleted the table using delete how is it showing me the error message.
Post #1399787
Lynn Pettis
Lynn Pettis
Posted Sunday, December 23, 2012 10:29 PM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 8:51 PM
Points: 21,832,
Visits: 27,861
Shadab Shah (12/23/2012)
I create a table as
CREATE TABLE DEMO (A INT)
Then i deleted it as follow
DELETE DEMO
I tried to again recreate the table using the same above statement, But it gave me the following error message
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'DEMO' in the database.
Now over here i am trying to understand when i deleted the table using delete how is it showing me the error message.
DELETE does not drop a table, it is used to delete records from a table. To drop a table you use DROP TABLE tablename;.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #1399799
SQLRNNR
SQLRNNR
Posted Sunday, December 23, 2012 10:54 PM
SSCoach
Group: General Forum Members
Last Login: Today @ 3:33 PM
Points: 18,858,
Visits: 12,443
Lynn is correct. If you need to remove the table, you need to use DROP. If you are only trying to remove records, then DELETE is what you will use.
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1399802
hcprasadv
hcprasadv
Posted Sunday, December 23, 2012 11:18 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Yesterday @ 8:08 AM
Points: 144,
Visits: 269
When you run DELETE, every row will be removed from the table.
TRUNCATE TABLE statement also removes all rows from a table. TRUNCATE TABLE has several advantages over DELETE, when used to remove all rows from a table. TRUNCATE TABLE uses less transaction log space, requires fewer locks, and leaves zero pages for the table.
BUT Delete or Truncate does not remove Objects completely.Use DROP
instead of Delete or Truncate.
use DROP TABLE DEMO instead of Delete or Truncate
Post #1399804
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.