Click here to Skip to main content
15,897,718 members
Home / Discussions / Database
   

Database

 
GeneralRe: Is it possible to get create/alter/drop scripts from within a SP in SQL server 2005? Pin
Mycroft Holmes24-Nov-09 18:15
professionalMycroft Holmes24-Nov-09 18:15 
GeneralRe: Is it possible to get create/alter/drop scripts from within a SP in SQL server 2005? Pin
Jon_Boy24-Nov-09 7:07
Jon_Boy24-Nov-09 7:07 
GeneralRe: Is it possible to get create/alter/drop scripts from within a SP in SQL server 2005? Pin
Ashfield24-Nov-09 21:11
Ashfield24-Nov-09 21:11 
GeneralRe: Is it possible to get create/alter/drop scripts from within a SP in SQL server 2005? Pin
Jon_Boy25-Nov-09 1:18
Jon_Boy25-Nov-09 1:18 
QuestionDuplicate Remover Pin
Vimalsoft(Pty) Ltd24-Nov-09 1:42
professionalVimalsoft(Pty) Ltd24-Nov-09 1:42 
AnswerRe: Duplicate Remover Pin
Niladri_Biswas24-Nov-09 2:38
Niladri_Biswas24-Nov-09 2:38 
GeneralRe: Duplicate Remover Pin
Vimalsoft(Pty) Ltd24-Nov-09 2:42
professionalVimalsoft(Pty) Ltd24-Nov-09 2:42 
GeneralRe: Duplicate Remover [modified] Pin
Niladri_Biswas24-Nov-09 3:22
Niladri_Biswas24-Nov-09 3:22 
Try this

declare @t table(sal1 int,sal2 int,dur1 int,dur2 int)
insert into @t 
	select 6,7,3,2 union all select 6,7,3,3 union all
	select 354,867,1,2 union all select 354,867,1,3 union all
	select 354,872,1,2 union all select 354,872,1,3 union all
	select 356,867,1,2 union all select 356,867,1,3 union all
	select 356,872,1,2 union all select 356,872,1,3
	
select * from @t


I am taking this RecordSet

sal1	sal2	dur1	dur2
6	7	3	2
6	7	3	3
354	867	1	2
354	867	1	3
354	872	1	2
354	872	1	3
356	867	1	2
356	867	1	3
356	872	1	2
356	872	1	3


Since you want any one of the record set so I can use either

sal1	sal2	dur1	dur2
6	7	3	2


or

sal1	sal2	dur1	dur2
6	7	3	3


If this assumption of mine is correct, the here is the answer

select sal1,sal2,dur1,dur2 from(
select row_number() over(partition by sal1,sal2 order by sal1,sal2) rn, sal1,sal2,dur1,dur2 from @t) X
where rn = 1


Output:

sal1	sal2	dur1	dur2
6	7	3	2
354	867	1	2
354	872	1	2
356	867	1	2
356	872	1	2


Here I am considering only the first one for every duplicate entries

What next you can do is put this record set in some temp table , delete the original one and then insert this record back into the table.

Please let me know in case of any concern.

Note - This code will work for Sql server 2005+
Smile | :)

Niladri Biswas

modified on Tuesday, November 24, 2009 9:31 AM

AnswerRe: Duplicate Remover Pin
Mycroft Holmes24-Nov-09 18:20
professionalMycroft Holmes24-Nov-09 18:20 
QuestionExporting a report on tables' structure in Oracle Pin
Muammar©23-Nov-09 4:30
Muammar©23-Nov-09 4:30 
AnswerRe: Exporting a report on tables' structure in Oracle Pin
David Mujica23-Nov-09 5:12
David Mujica23-Nov-09 5:12 
GeneralRe: Exporting a report on tables' structure in Oracle Pin
Muammar©23-Nov-09 7:09
Muammar©23-Nov-09 7:09 
AnswerRe: Exporting a report on tables' structure in Oracle Pin
Jörgen Andersson23-Nov-09 21:04
professionalJörgen Andersson23-Nov-09 21:04 
QuestionHow to take a number which compare nearby some numbers ? Pin
Golden Jing22-Nov-09 22:33
Golden Jing22-Nov-09 22:33 
AnswerRe: How to take a number which compare nearby some numbers ? Pin
Blue_Boy22-Nov-09 23:03
Blue_Boy22-Nov-09 23:03 
GeneralRe: How to take a number which compare nearby some numbers ? Pin
Golden Jing22-Nov-09 23:13
Golden Jing22-Nov-09 23:13 
GeneralRe: How to take a number which compare nearby some numbers ? Pin
Blue_Boy22-Nov-09 23:29
Blue_Boy22-Nov-09 23:29 
AnswerRe: How to take a number which compare nearby some numbers ? Pin
Shameel22-Nov-09 23:47
professionalShameel22-Nov-09 23:47 
AnswerRe: How to take a number which compare nearby some numbers ? Pin
Luc Pattyn23-Nov-09 1:36
sitebuilderLuc Pattyn23-Nov-09 1:36 
GeneralRe: How to take a number which compare nearby some numbers ? Pin
Shameel23-Nov-09 2:16
professionalShameel23-Nov-09 2:16 
AnswerRe: How to take a number which compare nearby some numbers ? Pin
Shameel23-Nov-09 4:00
professionalShameel23-Nov-09 4:00 
GeneralRe: How to take a number which compare nearby some numbers ? Pin
Luc Pattyn23-Nov-09 4:28
sitebuilderLuc Pattyn23-Nov-09 4:28 
GeneralRe: How to take a number which compare nearby some numbers ? Pin
Roger Wright24-Nov-09 19:04
professionalRoger Wright24-Nov-09 19:04 
GeneralRe: How to take a number which compare nearby some numbers ? Pin
Luc Pattyn25-Nov-09 2:21
sitebuilderLuc Pattyn25-Nov-09 2:21 
GeneralRe: How to take a number which compare nearby some numbers ? Pin
Roger Wright25-Nov-09 2:47
professionalRoger Wright25-Nov-09 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.