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 2000 Forums
 SQL Server Development (2000)
 Morning braindead

Author  Topic 

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-05-26 : 11:23:47
I need to add a Unique constraint to a field on a existing table.

however there is all ready alot of dupes in that field.

I tried several variations of count to no avail.

Any Ideas???

Jim
Users <> Logic

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-05-26 : 11:39:30
[code]
select field1, count(*) from mytable group by field1 having count(*) > 1
[/code]

Possibly??
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-05-26 : 13:20:12
Thanks Rick (boy do I feel stupid)

Jim
Users <> Logic
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-26 : 13:22:28
And if you want to delete the duplicates:

http://www.sqlteam.com/item.asp?ItemID=3331

Tara
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-05-26 : 13:25:54
Thanks Tara

There were only 35 dupes out of 265,000 records.

It was faster to clean it by hand.

Jim
Users <> Logic
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-05-26 : 13:29:45
quote:
Originally posted by JimL

Thanks Tara

There were only 35 dupes out of 265,000 records.

It was faster to clean it by hand.

Jim
Users <> Logic



Where you playing Ranger over the weekend?





Brett

8-)
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-05-27 : 05:22:52
quote:
Originally posted by JimL

Thanks Rick (boy do I feel stupid)

Jim
Users <> Logic


We all get our moments...
Go to Top of Page
   

- Advertisement -