Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF EXISTS DROP TABLE

Status
Not open for further replies.

pvuppa1

Programmer
Nov 14, 2003
61
0
0
US
can anyone tell me how to verify if table exists before I issue DROP TABLE JOBS for the following statement

SET SQLENGINE=SQLMSS
SQL SQLMSS SET SERVER CONN1
SET COMMIT = ON
SQL SQLMSS
BEGIN TRANSACTION
DROP TABLE JOBS
COMMIT WORK ;
END

by the way, im getting this error message when I try to drop a table which is no longer existing.

FOC1400) SQLCODE IS 3701 (HEX: 00000E75) XOPEN: 42S02
: Microsoft OLE DB Provider for SQL Server: [42S02] Cannot drop the table
: 'JOBS', because it does not exist in the system catalog.
(FOC1414) EXECUTE IMMEDIATE ERROR.

thanks in advance
Appreciate ur help

-P
 
Try:

BEGIN TRANSACTION
IF EXISTS (SELECT * FROM dbo.sysobjects where id = object_id(N'[dbo].[jobs]')AND
OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE JOBS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top