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
APD TorontoSoftware DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
IF OBJECT_ID( N'dbo.agent_rates' ) IS NOT NULL
      DROP TABLE dbo.agent_commissions;

So ... if agent_rates exists, drop agent_commissions?   Is this a typo, and should be...

IF OBJECT_ID( N'dbo.agent_commissions' ) IS NOT NULL
      DROP TABLE dbo.agent_commissions;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.