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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Attack of the Duplicates
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Drummos
Starting Member

USA
4 Posts

Posted - 02/11/2007 :  14:48:50  Show Profile  Reply with Quote
Help, lol. I recently imported all my table data into a new database on a new Win Server 2003 from SQL 2005 to SQL 2005. I went in to set my PK on the new tables.

Come to find out, all my records were duplicated. So, I followed the advice in an article on this forum about deleting duplicate records.

That worked. But, the duplicate records refuse to be beaten so easily. Every time I go in to create my PK a new single duplicate appears. I'm not sure what is happening but all my tables are experiencing this issue.

If anyone can help me out I'd be eternally grateful.

Thanks,


Ally

eyechart
Flowing Fount of Yak Knowledge

USA
3575 Posts

Posted - 02/11/2007 :  15:25:06  Show Profile  Reply with Quote
Have you run the SQL statement that lists the dupe records? Something like:

SELECT val1,
COUNT(val1) AS Kount
FROM table_name
GROUP BY val1
HAVING (COUNT(val1) > 1)

Since you haven't given us any details about your table, you are going to have to substitute the proper column and table names into the query.

This will show you the dupe values that you will need to fix.

Also, keep in mind that you cannot have NULLs in the column you are trying to apply the PK to. So, be sure that this issue is not occuring becuase you have a single NULL somewhere.


-ec

Edited by - eyechart on 02/11/2007 15:25:35
Go to Top of Page

Drummos
Starting Member

USA
4 Posts

Posted - 02/11/2007 :  16:07:20  Show Profile  Reply with Quote
You know I did do that but for the sake of double checking I did it again. This time I found three duplicate records, deleted them, and I did not have any problems and could set the key. Go figure. Maybe I just needed to establish a fresh connection. I logged off earlier in frustration.

It was just wierd. Thanks, I'll give this another whirl. Wish me luck.


Ally
Go to Top of Page

Drummos
Starting Member

USA
4 Posts

Posted - 02/11/2007 :  16:12:57  Show Profile  Reply with Quote
OH! You know what I think I know what caused my problem. I took a drive out to the office to see if what I was experiencing was some strange side effect caused by logging in remotely. It wasn't, the records were duplicated on the server.

However, I found that one of my employees was logged onto the local server, probably doing some work in the database. He did not log off and the server was locked. I bet it was preventing me from making changes. I logged him off before I left. I bet that was the problem. :)

Ally
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000