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
185 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 65

Accepted Solution

by:
Jim Horn earned 500 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

776 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