Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

DELETE Tables in SQL

I am trying to delete tables in SQL but it realy does not seem to be deleting them because when I add a field to a table I create in the query it has an error like field name doesnt exist

IF EXISTS (SELECT * 
           FROM   information_schema.tables 
           WHERE  table_name = 'Temp_MyTools') 
  DROP TABLE temp_mytools; 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
IF OBJECT_ID('tempdb.dbo.Temp_MyTools', 'U') IS NOT NULL
  DROP TABLE Temp_MyTools;

Open in new window

>when I add a field to a table I create in the query
So ... you are trying to delete (i.e. DROP, kill the table, terminate, asta la vista baby, blow away...) a table, but then later on add a column to it?

By any chance does 'delete' really mean 'remove all rows' from the table, which would be either of these two..
DELETE FROM Temp_MyTools
TRUNCATE TABLE Temp_MyTools

Open in new window

Avatar of r3nder

ASKER

Thanks Jim