Question:
I am trying to create a procedure that first drops the table “table” but only if it already exists.
How do I create the statement using “if exists” or something similar to this?
Drop table mytableselect * into mytablefrom othertable
This statement returns an error if the table does not already exist.
Answer:
What you are after is this:
IF EXISTS (SELECT name FROM sysobjects WHERE type = 'U') DROP TABLE mytableEND
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.























