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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress Errors/Warnings

Status
Not open for further replies.

christywarner

Programmer
Apr 14, 2003
32
US
Hi,

I have an Access front-end w/ SQL Server back-end.
I have a stored procedure that checks to see if a
SQL server file exists, and if so, it deletes it.
The only problem is, once the file is delete,
the stored proc gives me an error that the file
doesn't exist. How do I suppress these messages?
I tried in Access docmd.setwarnings false, but I
think this only applies to native Access VBA code,
not the SQL server side.

Here is my stored proc:

CREATE PROCEDURE EXISTDROP AS
IF EXISTS (SELECT * FROM NEWTABLE)
BEGIN
DROP TABLE NEWTABLE
END
GO

thanks!
Christy.
 
If you are working with SQL2K, then you can use one of the Information_Schema views to see if a table exists:

Code:
CREATE PROCEDURE EXISTDROP AS
  IF EXISTS (SELECT * FROM Information_Schema.Tables
             WHERE Table_Name = 'NEWTABLE')
  BEGIN
     DROP TABLE NEWTABLE
  END
GO

The code is slightly different for previous versions of SQL. How does this work for you?

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top