473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SQL Collation Problem

I have a large (ish) number of databases that various people where I
work have created over the last few years. The problem is that no-one
here really understands collations and a mistake made originally keeps
cropping up and causing problems depending on where the create table
script has come from.

What happens is that someone needs to create a new database (new
client) and they pick an existing one, create the script (often
forgetting indexing, and they don't understand that either) and off
they go with a new copy.

Most of the time we get away with it, but when writing various things
I get errors about the conversion not being able to be performed.

I can change the scripts to forcibly use a certain collation, but
that's the wrong approach as it may impact other things down the line.
It would also mean re-writing a fair chunk of SP's and views etc...
With the added problem that this may be different from one database to
another. The database could be in one collation and tables could
either be the same, or a different one entirely and not consistent
between copies for different clients. In short, it's in a mess.

The two collations in question are :

Latin1_General_CI_AS and
SQL_Latin1_General_CP1_CI_AS

My ideal way of solving this would be to export the data somewhere and
re-create the entire db with a proper script and then import the data
again. Is this a sensible option ? What options are available to me
and what is the best way of correcting this ? Is there a quick way of
doing this ?

Thanks in advance
Ryan

Feb 1 '07 #1
2 4641
Should have mentioned, it's SQL2000

Feb 1 '07 #2
Ryan (ry********@hotmail.com) writes:
The two collations in question are :

Latin1_General_CI_AS and
SQL_Latin1_General_CP1_CI_AS

My ideal way of solving this would be to export the data somewhere and
re-create the entire db with a proper script and then import the data
again. Is this a sensible option ? What options are available to me
and what is the best way of correcting this ? Is there a quick way of
doing this ?
You can use ALTER TABLE ALTER COLUMN to change the collation of each
column. Those commands can easilly be created by running a query against
syscolumns. However, you cannot change the columns on indexed columns,
so you need to drop all indexes, including primary keys. And to be able to
drop primary keys, you must also drop referring foreign keys. And then
restore these once you're done.

So in the end, it may be better to build an empty database from scripts,
preferrably taken from version-control, but if there is no such thing,
you would have to generate scrtips. Whatever, make sure that the script
has no COLLATE clauses at all, and that the new database uses the server
collation.

While you could bulk-in and bulk-out, you could also move the data
by means of INSERT. In this case, it would be better to disable foreign
keys, and then reenable them once your done.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Feb 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Temba | last post by:
Hi there, I've been searching for about 6 hours to get a problem solved. I installed MySQL 4.1.7 on the Debian web-server. Normally this worked: insert into logbook...
2
by: amos | last post by:
hi i have a db with hebrew collation. i now want it to be cyrillic collation. converting the db collation - wont help. i tried exporting data to a blank DB created with cyrillic collation -...
2
by: Marco | last post by:
I need to migrate an application from SQL 7.0 to SQL 2000. I know that they use different collations, and this causes problems when 7.0 applications are moved to 2000. I would like to find a...
3
by: Matik | last post by:
Hello, I think I'd might have a small collation problem. Configuration: Two SQL Srv 2000 SP3 (running on clusters). Booth servers configured with SQL_Latin1_General_CP1_CI_AS collation. ...
7
by: Ryan | last post by:
I've stumbled across the above error and am a little stuck. I've just installed SQL2000 (sp3) on my PC and restored a database from our Live server. On a simple Update statement on a #temp table,...
3
by: David Greenberg | last post by:
Hi When we installed SqlServer2000 we left the default collation name (Sql_Latin1_General_CPI_CI_AS). The user defined databases we created afterwards were defined with a different collation name...
21
by: Peter Nurse | last post by:
I have just upgraded to SQL Server 2005 from SQL Server 2000. In Microsoft SQL Server Management Studio, when I click on database properties, I receive the following error:- Cannot resolve the...
27
by: Nasir | last post by:
Hi there, Is it posible to set the collation of SQL server 2005 like Oracle, which is that objects names and column names are case-insensitive, but data is sensitive;e.g: In Oracle: --create...
2
by: =?utf-8?B?UMSBdmVscyBNaWhhaWxvdnM=?= | last post by:
Hello, I have a problem. I've linked MySql server to MsSql, in MySql I have a table with Latvian data(character set is ucs2, ucs2_general_ci) and the problem is that when I use openquery to read...
3
by: aj | last post by:
A few collation questions on SQL Server 2005 SP2, which I'll call SQLS. The default collation for SQLS is apparently SQL_Latin1_General_CP1_CI_AS. I wish to use a variation of this,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.