Tuesday, February 14, 2012

Delete Multiple IDs

Hi,

I am getting doubles for all my IncidentIDs in IncidentID column.

Ex:

Incident ID

13734

Incident ID

13734

Is there a delete statement to get rid of more then one Replication of the same ID?

Thanks

There are numerous ways available to achieve this

Simplest way is Copy the table Data to temporary table, delete the data in original table, select distinct data from temporary table and insert into the original table

|||isnt there a query i can use?|||

try like this

select * into #temptable from yourtable

Go

Delete from yourtable

Go

Insert yourtable

Select distinct * from #temptable

Go

Drop table #temptable

|||where did all my data go in the original table?|||

I didn't get you properly, did u executed the mock script ? what's the result?

|||

i excecuted the script you have me filling 'yourtable' as the name of my current table and leaving #temptable as is.

I cannot find any data now..

|||Can you provide me your table structure and sample data|||

Most of the table looks like this, There are close to 13,000 of these records. For some odd reason now theres 26,000 due to the double copy/replication of each record. i just want to delete the 2nd copy. After I ran your mock query everything is missing.

Columns: Sample Data:

Incident Id 1212

Description Cannot get program to run.

Resolution Double clicked wrong icon.

|||

I tested the procedure again, It is working as desired

Let me know the Exact sql statements you used

No comments:

Post a Comment