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.
| Author |
Topic |
|
MGA
Starting Member
28 Posts |
Posted - 2010-09-28 : 05:41:36
|
| i have a clients table that contains client_id and client_name columns and it contains already data , i want to write a sql command to test if the table has a duplicate values in the client_name field |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-09-28 : 05:54:53
|
| [code]select client_id,client_name from table group by client_id,client_name having count(*)>1[/code]PBUH |
 |
|
|
MGA
Starting Member
28 Posts |
Posted - 2010-09-28 : 06:05:35
|
| i want to write this sql command in a stored procedure and it should returns true or false only if it had any duplicated value |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-09-28 : 06:18:35
|
| [code]select client_id,client_name from table group by client_id,client_name having count(*)>1if @@rowcount>0return trueelsereturn false[/code]PBUH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-28 : 10:28:21
|
quote: Originally posted by Sachin.Nand
select client_id,client_name from table group by client_id,client_name having count(*)>1if @@rowcount>0return trueelsereturn false PBUH
orif exists(select client_id,client_name from table group by client_id,client_name having count(*)>1)return trueelsereturn falseMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|