Link to home
Create AccountLog in
Avatar of APD Toronto
APD TorontoFlag 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
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account