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
180 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now