Dynamics User Group
Since 1995 - The Microsoft Dynamics Online User Community

Changing collation in a SQL database

rated by 0 users
This post has 20 Replies | 2 Followers

Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator
Erik P. Ernst Posted: 11-09-2007 23:41

What's the best way to change the collation in a SQL 2005 database? Using the alter database from the NAV client or directly from SQL management studio?

I tried to do it from the NAV client, but approx. when it reach 69% complete then it stopped, as the transation log file could not grow more. The database was 18 GB and the log file had grown to 78 GB! (It was empty when I started)

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

Top 50 Contributor
Male
Posts 408
Points 6,270
Member since 08-05-2003
DynamicsNAVMVP
Rashed replied on 11-10-2007 4:01

How about doing a navision backup and create a new db with diff collation and restore the backup? 

Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator
Erik P. Ernst replied on 11-10-2007 11:27

That also crossed my mind, but it takes quite a lot of time to restore an 18 GB database... And as our operation is basically 24/7 then I'm looking for a way to minimize the time as much as possible.

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

Top 50 Contributor
Male
Posts 408
Points 6,270
Member since 08-05-2003
DynamicsNAVMVP
Rashed replied on 11-10-2007 13:21

You could disable all the keys. and enable them after collation change. You can also change the recovery model to simple Simple if that helps.

Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator

Well recovery model was already changed to simple... And disabling / enabling keys is the main reason why restoring takes so much time...

As I have seen if I want to do the collation change from the SQL Management Studio, then I must first do it on the database level, and then for all individual tables in the database. Is that true?

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

Top 50 Contributor
Male
Posts 408
Points 6,270
Member since 08-05-2003
DynamicsNAVMVP

 yes, a db has a collation and then every table has its own collation.

It's a big sql statement to change all the tables collation, I would rather do it from navision.

 

The other option is to do it in a small db. Turn on SQL profiler and capture all the sql statements, then do them from enterprise manager in test environment on another db, then in prod.

Top 500 Contributor
Male
Posts 58
Points 6,258
Member since 05-09-2005

If you just wanted to change the collation of the Master db you could do from within SQL but on the databases I recommend NAV backup and restore to an newly created db (with same collation in master for optimal performance). 20GB should't take more than 3-5 hours to restore having the right hardware (backup probably 1-2 hours) and performing the restore directly from the SQL server.

Best regards, Kim Mohr Larsen www.globeaccounting.com
Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator

Well actually creating a NAV backup is not an option. A large number of different errors are coming up when trying to do a NAV backup! I think it's due to the fact that we are running a lot of different character sets in the database already.

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

  • | Post Points: 20
Top 500 Contributor
Male
Posts 58
Points 6,258
Member since 05-09-2005

Yes it is not possible to do navision backup of companies where record have been entered with other codepages if windows collation.

KR

Kim

Best regards, Kim Mohr Larsen www.globeaccounting.com
  • | Post Points: 20
Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator

Just another reason to change to SQL collation!

Well I better gonna add some more space for that tlog file!

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

  • | Post Points: 20
Top 25 Contributor
Male
Posts 797
Points 5,350
Member since 07-03-2001
MicrosoftEmployee

Using a SQL collation does not avoid codepage mismatch issues.

Both SQL collations and Windows collations (the latter as single-byte, which NAV utilizes) depend on a selected code page which by default must match between the client and server when accessing a database.

The problem of having characters that were generated by a machine running a certain code page when doing a backup or export, then restoring/importing on a machine with a different code page is common to both collation types.

It is not even a "database collation" concept - merely a code page concept. It is the same if you edit a text file with an OEM editor using, e.g. code page 437, then give that to someone opening it with Notepad using ANSI 1252. Extended characters will be different.

Since NAV does not utilize either collation types as Unicode, you need to ensure that code pages are fixed, or use characters that do not suffer under conversion.

This posting is provided "AS IS" with no warranties, and confers no rights.
  • | Post Points: 20
Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator

Adding a different drive with a 100GB transaction log file did the trick. The collation is not set to the same for both server and db! And it's possible to run the NAV backup again.

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator

Dean McCrae:

Since NAV does not utilize either collation types as Unicode, you need to ensure that code pages are fixed, or use characters that do not suffer under conversion.

Ok, how would you then setup the server/database to allow have both ex. Danish, Greek, Turkish, Thai and Chinese characters (but in different companies and different Citrix front ends)?

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

Top 10 Contributor
Male
Posts 3,440
Points 106,041
Member since 10-01-1995
DynamicsNAVMVP
Moderator
SystemAdministrator

The question was partly answered in http://dynamicsuser.net/forums/t/20849.aspx. Please continue the debate about what collation to use in that thread. This thread was mainly a technical issue regarding basic task of chaning the collation.

Best regards,
Erik P. Ernst - webmaster at dynamicsuser.net

DynamicsUser.net Admin's Blog

  • | Post Points: 20
Top 500 Contributor
Male
Posts 58
Points 6,258
Member since 05-09-2005

I think Erik wanted to refer to this thread: http://dynamicsuser.net/forums/t/20679.aspx which is how it can be configured allowing different languages and codepages in one central db.

Best regards, Kim Mohr Larsen www.globeaccounting.com
  • | Post Points: 20
Page 1 of 2 (21 items) 1 2 Next > | RSS


Copyright Dynamics User Group, 1995-2009, all rights reserved. The Dynamics User Group is not affiliated with Microsoft Corporation.