Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to avoid duplicate values

Author  Topic 

sqlserver5
Starting Member

19 Posts

Posted - 2008-01-08 : 03:06:39

ename sname
billa raja
jj fks
billa raja
jj jfg

i need the output is following wise

ename sname
billa raja
jj fks
jfg

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-08 : 03:20:24
SELECT DISTINCT ename,sname
FROM Table
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-08 : 03:35:28
Same question as over here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95062



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-08 : 03:36:16
Well, the topic title is not the same as the question.
If you want to avoid duplicates, create a unique constraint/index.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-08 : 03:39:29
quote:
Originally posted by Peso

Same question as over here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95062



E 12°55'05.25"
N 56°04'39.16"



Expected result is not clear there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlserver5
Starting Member

19 Posts

Posted - 2008-01-08 : 03:55:23
No Peso

using
select distinct ename,loc,sal from emp
it will produce the result
but in that duplicate values are also occured
so only i asked how to avoid duplicate values

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-08 : 03:58:33
quote:
Originally posted by sqlserver5

No Peso

using
select distinct ename,loc,sal from emp
it will produce the result
but in that duplicate values are also occured
so only i asked how to avoid duplicate values




Can you post some sample data with expected result?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlserver5
Starting Member

19 Posts

Posted - 2008-01-08 : 03:59:08
yes visak16
your query will work
but how to avoid duplicate values
Go to Top of Page

sqlserver5
Starting Member

19 Posts

Posted - 2008-01-08 : 04:06:26
yes madhi
<u>table</u>
name dep loc
raja cs madurai
roja cs chennai
raja cs madurai

write a query for the following output

name dep loc
raja cs madurai
roja chennai
Go to Top of Page

sqlserver5
Starting Member

19 Posts

Posted - 2008-01-08 : 04:06:27
yes madhi
<u>table</u>
name dep loc
raja cs madurai
roja cs chennai
raja cs madurai

write a query for the following output

name dep loc
raja cs madurai
roja chennai
Go to Top of Page

sqlserver5
Starting Member

19 Posts

Posted - 2008-01-08 : 04:07:25
how to align the text in the msg box in forum
Go to Top of Page

sqlserver5
Starting Member

19 Posts

Posted - 2008-01-08 : 04:48:44
Dear madhi
can you get my data
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-08 : 05:40:38
quote:
Originally posted by sqlserver5

Dear madhi
can you get my data



I answered here
Refer http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95062

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -