Help with Delete query in SQL.

I have a SQL database that populates tables on my local machine.  I then upload this data to a SQL database that is being hosted with Microsoft Azure.  Typically when I am done uploading the data to Azure, I delete it locally.  I do this for backups and to give my clients access to it.

I have one local table that I am having a hard time deleting data from.  I have 4 columns that also constitute the key.   I have a screenshot below.  These four columns will always produce a unique row, however any one of these columns by themselves will not.

Below is an example of data that I want to delete locally.  These are database records that are locally stored and in Azure.  Since they are in Azure, I want to delete them locally.

select c.[statusId], c.[classifierName], c.[className], c.[classValue] 
FROM [dbo].[classifications] c
Inner join [AzureSQL].[MyDb].[dbo].[classifications] ac on 
	c.statusId = ac.statusId 
	and c.classifierName = ac.classifierName
	and c.className = ac.className
	and c.classValue = ac.classVale

Open in new window


How can I update this query to delete my local records?

My local table is [dbo].[classifications]

While my Azure table is [AzureSQL].[MyDb].[dbo].[classifications]

Also, Azure is setup as a linked server.  Any help would be greatly appreciated.
screenshot.jpg
rye004Asked:
Who is Participating?

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

x
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.

ste5anSenior DeveloperCommented:
Instead of SELECT columnlist FROM use DELETE aliasname FROM. Thus this should work:

DELETE c
FROM [dbo].[classifications] c
Inner join [AzureSQL].[MyDb].[dbo].[classifications] ac on 
	c.statusId = ac.statusId 
	and c.classifierName = ac.classifierName
	and c.className = ac.className
	and c.classValue = ac.classVale

Open in new window


And as always: make backups first, before testing :)
0

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
rye004Author Commented:
I tried that and I get the following:

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'c'.

Thanks for your help!
0
rye004Author Commented:
Actually, it did work!  I made a typo.  Thanks!
0
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.