In order to avoid getting this error and to be able to run this Select statement multiple times by selecting into the same table, we need to add the following code to
1. check for the Existence of this table in the database,
2. drop the table if it already exists
3. Then run the Select statement with the Into Clause
IF EXISTS (SELECT * FROM sys.objects WHERE object_id =OBJECT_ID(N'[dbo].[Table1]') AND type in (N'U'))
BEGIN
Drop table Table1
END
Very good tip. You know, you have updated most of my reports with a similar line and it has proven to be quite useful.
ReplyDelete