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)
 Collation problem while creating foreign key

Author  Topic 

Nikolai
Starting Member

1 Post

Posted - 2003-10-01 : 04:19:32
Hi there!

When Iam trying to create a foreign key, it gives me an error :
Column 'Table1.Field' is not of same collation as
referencing column 'Table2.Field' in foreign key 'FK_BLAHBLAHBLAH'

The database collation was changed using
ALTER DATABASE data1 COLLATE Latin1_General_CI_AS

And collationid column in syscolumns table was updated too.


What am I doing wrong here?

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2003-10-01 : 09:34:39
It looks like you have a mismatch in the definition of 2 fields you are trying to link.


When creating a constraint (like a FK) between 2 fields, SQL wants both fields to be defined the same....ie both char(20) and also it seems both to be the same COLLATION.


right-click in EM opn both tables...and produce the DDL script for both tables....the difference should be visible there.

The solution is to change the COLLATION of one or the other of the fields to be the same COLLATION as the non-changing field.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-10-01 : 12:57:16
>> And collationid column in syscolumns table was updated too.
That sounds like a concern - did you just update the system table directly?

I would recreate the two tables and copy the data.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-10-01 : 13:03:38
Why would you update the sytem tables directly? Why don't you just specify the collation when you CREATE the table? Updating the system tables should not be done, especially for something as easy as this.

Tara
Go to Top of Page
   

- Advertisement -