September 20, 2007 at 12:31 am
Hi,
Can anyone please help me
I want the answer for this in SQL Server 2000.
I have a table containing fields as Name and Salary.Name is varchar data type and Salary int data type.
I want to eliminate duplicate records.
A 12000
B 15000
C 13000
A 12000
A 12000
B 15000
C 13000
B 15000
A 12000
I want the result as
A 12000
B 15000
C 13000
Thanks in advance
September 20, 2007 at 12:41 am
There are two options here.
select distinct field1, field2
from table
or
select field1, field2
from table
group by field1, field2
Option 1 is the better for performance if you have a large table
September 20, 2007 at 12:46 am
That is fine
But I want to get the duplicate records deleted from my table
and get the final result
how is this possible in sql 2000
Thanks
September 20, 2007 at 12:54 am
select distinct name,salary
into #temptab
from tablename
truncate table tablename
insert into tablename
select name,salary from #temptab
regards
September 20, 2007 at 1:01 am
Thanks Sanjay.
It is working fine
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply