Avatar of APD Toronto
APD Toronto
Flag for Canada asked on

Drop table if exists, MSSQL, Part 2

Hi Expert,

This is a continuation from my last post... I am trying to create a table using the following code

/*Agent's commission rates*/

USE CSS_Reservations;

/*Drop and Create MySQL-formatted table*/
IF OBJECT_ID( N'dbo.agent_rates' ) IS NOT NULL
	DROP TABLE dbo.agent_commissions;

CREATE TABLE dbo.agent_commissions
	(agent_id INT NOT NULL , product_id VARCHAR(6) NOT NULL , 
	 family DECIMAL(5,2) NOT NULL , adult DECIMAL(5,2) NOT NULL , senior DECIMAL(5,2) NOT NULL ,
	 student DECIMAL(5,2) NOT NULL , child DECIMAL(5,2) NOT NULL , infant DECIMAL(5,2) NOT NULL);

Open in new window


But I keep getting
Msg 2714, Level 16, State 6, Line 9
There is already an object named 'agent_commissions' in the database.

However, isn't this taken care of on lines 6-7?

Thank you
Microsoft SQL ServerMicrosoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Jim Horn

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jim Horn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes