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 |
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2006-12-05 : 13:59:00
|
Hello,I am writing a SQL procedure and I need to check if in MyTable there is only one record where field [NAME] = @Name or if there is more then one.How can I do this?Thanks,Miguel |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-05 : 14:16:33
|
select count(*) from MyTable where [NAME] = @Name |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-06 : 10:59:52
|
To find all names having more than one recordselect Name,count(*) from MyTable Group by NameHaving count(*)>1MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|