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
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 66

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.

688 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