?
Solved

I need a query to Delete a SITE_ID entry for a dbo.MERC_SITE in SQL Server 2008

Posted on 2014-04-16
2
Medium Priority
?
200 Views
Last Modified: 2014-04-16
Hello all,

I am needing to run a query to delete an entry from the table dbo.MERC_SITE and am not sure how to go about it.  

I know to use this query when I need to change the SITE_ID from one to another when a mistake happens:

use poswest
update dbo.MERC_SITE
set SITE_ID='A5532592'--New Site ID you wish to have.
Where SITE_ID='A5532592'--Old Site ID you are replacing.

But I am not sure how to use a query to delete an entry.  Can someone help me with this?
0
Comment
Question by:IT Tech
2 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 40005282
DELETE FROM dbo.MERC_SITE WHERE Where SITE_ID='A5532592'

Open in new window

Or to make life easy on yourself, bundle the whole thing in a transaction, to make sure both statements succeed or fail together:
BEGIN TRAN tr

update dbo.MERC_SITE
set SITE_ID='A5532592'--New Site ID you wish to have.
Where SITE_ID='A5532592_old'--Old Site ID you are replacing.

DELETE FROM dbo.MERC_SITE Where SITE_ID='A5532592_old'

COMMIT TRAN tr

Open in new window

0
 

Author Comment

by:IT Tech
ID: 40005347
I thank you for the help on this one. I am so glad to have this resource available. Always grateful for the help you provide.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question