SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Article: Deleting Duplicate Records
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 3

expert
Starting Member

4 Posts

Posted - 09/23/2011 :  10:11:17  Show Profile  Reply with Quote
This link provides different methods of delete duplicate rows in sql

http://www.besttechtools.com/SQLArticles.aspx?ID=DeleteDuplicate
Go to Top of Page

ktomb
Starting Member

USA
2 Posts

Posted - 11/30/2011 :  22:22:46  Show Profile  Reply with Quote
What if you just didn't want to count the duplicates, or report the duplicates? But you don't want to delete anything.

Ex. Service code xyz is in GL 12345 and also in GL 34567, all other information is the same (account number, etc) i don't want to count or report the duplicate if it's already being counted or reported by the first GL in the hierarchy. Ex. if it's in GL 12345 then I don't want to count/report on it if it's also in GL 34567.
Go to Top of Page

petersJazz
Starting Member

Sweden
5 Posts

Posted - 01/16/2012 :  08:55:57  Show Profile  Visit petersJazz's Homepage  Reply with Quote
I found a way. In Oracle you would use the column value ROWID. In SQL Server you can use the column %%physloc%% to get a id for every row. If you want to remove one of the row in a table that has no unique index you can do something like this. Please test it out first before using it.
delete from table a
-- select a.*,%%physloc%% -- when testing it out
where 0 =
(select count(*)
from table b
where a.id = b.id
and b.%%physloc%% > a.%%physloc%%)


petersJazz
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30114 Posts

Posted - 01/16/2012 :  16:57:26  Show Profile  Visit SwePeso's Homepage  Reply with Quote
No, you can't. There are a few rules that must be met before using %%physloc%%.
See http://sqlfool.com/2009/09/undocumented-function-in-sql-2008/



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

steve.caplin77
Starting Member

USA
3 Posts

Posted - 01/27/2012 :  14:08:35  Show Profile  Reply with Quote
unspammed
Go to Top of Page

bhaskarareddy
Starting Member

7 Posts

Posted - 06/06/2012 :  06:31:22  Show Profile  Reply with Quote
hi

refer this link

http://csharpektroncmssql.blogspot.com/2011/11/how-to-delete-duplicate-rows-from-table.html
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000