Showing posts with label collation. Show all posts
Showing posts with label collation. Show all posts

Thursday, March 29, 2012

Changing the system (master) collation setting in SQL Server 2005 Express Edition

Does anyone know how to do the above without having to re-install SQL Server?

Cheers

Simon.

This is documented in the Books Online Topic located at ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/3242deef-6f5f-4051-a121-36b3b4da851d.htm or on MSDN at http://msdn2.microsoft.com/en-us/library/ms179254(en-US,SQL.90).aspx

Cheers,
Dan

Tuesday, March 27, 2012

changing the SORT Collations

H
I am very new in SQL2000. My question is , is it possible to change the sort collation in SQL2000 after installation and how. Currently my server is set to case sensitive. how do I change it to case insensitive?
Also is it possible to do this on my select command instead? For instance, my server is case sensitive, but what i want to do is when I do a select command, I would temporarily remove the case sensitivity so it can get the desired results. This setting is only temporary and it goes back to the original setting once the session is diconnected. Is there a way to do this
Thank youCollation in SQL 2000 is now a per database setting. Before you had to
reinstall SQL to change the collation, and you could not load databases that
had a different sort setting.
In SQL 2000, you can set the collation on a server, database, table and
obviously transact-SQL level setting. To change the sort order for the
server, you have to detach all databases, uninstall and reinstall SQL in the
desired sort order, then convert the existing databases into new ones to
change the sort.
To change the sort of a database do ALTER DATABASE <db_name> COLLATE <new
collation order>
To alter a table, you can change the characters columns with ALTER TABLE
ALTER TABLE MyTable ALTER COLUMN ColumnName
[varchar|char](size) COLLATE <new collation order> [NOT
NULL|NULL]
Read more about it by downloading SQL books online from
http://www.microsoft.com/sql and looking up 'change collation'. Good luck.
--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
*******************************************************************
"DaSaint" <anonymous@.discussions.microsoft.com> wrote in message
news:592DF876-0E85-4B52-8733-7A4D52D62DB7@.microsoft.com...
> Hi
> I am very new in SQL2000. My question is , is it possible to change the
sort collation in SQL2000 after installation and how. Currently my server
is set to case sensitive. how do I change it to case insensitive?
> Also is it possible to do this on my select command instead? For
instance, my server is case sensitive, but what i want to do is when I do a
select command, I would temporarily remove the case sensitivity so it can
get the desired results. This setting is only temporary and it goes back to
the original setting once the session is diconnected. Is there a way to do
this?
> Thank you|||The collation on the sql server 2000 is database-specific. That means you
can create your application database with any collation you want.
To do that use, for exaple,
CREATE DATABASE dbname
COLLATE SQL_Latin1_General_CP1_CI_AI
If you want your database with one collation, having, for example, case
insensitive, and you want that one field of one table to be case sensitive,
you can do that by using:
CREATE TABLE mytable (
ID int primary key identity(1,1),
NAME nvarchar(256) COLLATE SQL_Latin1_General_CP1_CS_AI
But, if you want to rebuild your master database (that defines your system
tables collation), you can use the rebuild master using a utility.
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rebldmst/rebldmst_24aa.asp.
"DaSaint" <anonymous@.discussions.microsoft.com> wrote in message
news:592DF876-0E85-4B52-8733-7A4D52D62DB7@.microsoft.com...
> Hi
> I am very new in SQL2000. My question is , is it possible to change the
sort collation in SQL2000 after installation and how. Currently my server
is set to case sensitive. how do I change it to case insensitive?
> Also is it possible to do this on my select command instead? For
instance, my server is case sensitive, but what i want to do is when I do a
select command, I would temporarily remove the case sensitivity so it can
get the desired results. This setting is only temporary and it goes back to
the original setting once the session is diconnected. Is there a way to do
this?
> Thank you|||Thanks andy and francisco for the info!!

changing the SORT Collations

Hi
I am very new in SQL2000. My question is , is it possible to change the sor
t collation in SQL2000 after installation and how. Currently my server is s
et to case sensitive. how do I change it to case insensitive?
Also is it possible to do this on my select command instead? For instance,
my server is case sensitive, but what i want to do is when I do a select com
mand, I would temporarily remove the case sensitivity so it can get the desi
red results. This setting
is only temporary and it goes back to the original setting once the session
is diconnected. Is there a way to do this?
Thank youCollation in SQL 2000 is now a per database setting. Before you had to
reinstall SQL to change the collation, and you could not load databases that
had a different sort setting.
In SQL 2000, you can set the collation on a server, database, table and
obviously transact-SQL level setting. To change the sort order for the
server, you have to detach all databases, uninstall and reinstall SQL in the
desired sort order, then convert the existing databases into new ones to
change the sort.
To change the sort of a database do ALTER DATABASE <db_name> COLLATE <new
collation order>
To alter a table, you can change the characters columns with ALTER TABLE
ALTER TABLE MyTable ALTER COLUMN ColumnName
[varchar|char](size) COLLATE <new collation order> [NOT
NULL|NULL]
Read more about it by downloading SQL books online from
http://www.microsoft.com/sql and looking up 'change collation'. Good luck.
****************************************
***************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
****************************************
***************************
"DaSaint" <anonymous@.discussions.microsoft.com> wrote in message
news:592DF876-0E85-4B52-8733-7A4D52D62DB7@.microsoft.com...
> Hi
> I am very new in SQL2000. My question is , is it possible to change the
sort collation in SQL2000 after installation and how. Currently my server
is set to case sensitive. how do I change it to case insensitive?
> Also is it possible to do this on my select command instead? For
instance, my server is case sensitive, but what i want to do is when I do a
select command, I would temporarily remove the case sensitivity so it can
get the desired results. This setting is only temporary and it goes back to
the original setting once the session is diconnected. Is there a way to do
this?
> Thank you|||The collation on the sql server 2000 is database-specific. That means you
can create your application database with any collation you want.
To do that use, for exaple,
CREATE DATABASE dbname
COLLATE SQL_Latin1_General_CP1_CI_AI
If you want your database with one collation, having, for example, case
insensitive, and you want that one field of one table to be case sensitive,
you can do that by using:
CREATE TABLE mytable (
ID int primary key identity(1,1),
NAME nvarchar(256) COLLATE SQL_Latin1_General_CP1_CS_AI
But, if you want to rebuild your master database (that defines your system
tables collation), you can use the rebuild master using a utility.
See
http://msdn.microsoft.com/library/d... />
_24aa.asp.
"DaSaint" <anonymous@.discussions.microsoft.com> wrote in message
news:592DF876-0E85-4B52-8733-7A4D52D62DB7@.microsoft.com...
> Hi
> I am very new in SQL2000. My question is , is it possible to change the
sort collation in SQL2000 after installation and how. Currently my server
is set to case sensitive. how do I change it to case insensitive?
> Also is it possible to do this on my select command instead? For
instance, my server is case sensitive, but what i want to do is when I do a
select command, I would temporarily remove the case sensitivity so it can
get the desired results. This setting is only temporary and it goes back to
the original setting once the session is diconnected. Is there a way to do
this?
> Thank you|||Thanks andy and francisco for the info!!

Changing the server collations SQL 2005 Express

How do you change the collation on the master and temp DB
Thanks
Anthony
Hello,
As far as I know you cant change the collation of system databases directly.
To do this you may need to rebuild the master database.
http://support.microsoft.com/?kbid=325335#7
Thanks
Hari
"Anthony" <Anthony@.discussions.microsoft.com> wrote in message
news:72FBD92B-A5E3-488D-8E60-56C6A36B48AA@.microsoft.com...
> How do you change the collation on the master and temp DB
> Thanks
> Anthony
|||Thanks for the reply.
but this is for sql 2005 not 2000. It is not done in the same way.
"Hari Prasad" wrote:

> Hello,
> As far as I know you cant change the collation of system databases directly.
> To do this you may need to rebuild the master database.
> http://support.microsoft.com/?kbid=325335#7
> Thanks
> Hari
>
> "Anthony" <Anthony@.discussions.microsoft.com> wrote in message
> news:72FBD92B-A5E3-488D-8E60-56C6A36B48AA@.microsoft.com...
>
>
sql

Changing the server collations SQL 2005 Express

How do you change the collation on the master and temp DB
Thanks
AnthonyHello,
As far as I know you cant change the collation of system databases directly.
To do this you may need to rebuild the master database.
http://support.microsoft.com/?kbid=325335#7
Thanks
Hari
"Anthony" <Anthony@.discussions.microsoft.com> wrote in message
news:72FBD92B-A5E3-488D-8E60-56C6A36B48AA@.microsoft.com...
> How do you change the collation on the master and temp DB
> Thanks
> Anthony|||Thanks for the reply.
but this is for sql 2005 not 2000. It is not done in the same way.
"Hari Prasad" wrote:
> Hello,
> As far as I know you cant change the collation of system databases directly.
> To do this you may need to rebuild the master database.
> http://support.microsoft.com/?kbid=325335#7
> Thanks
> Hari
>
> "Anthony" <Anthony@.discussions.microsoft.com> wrote in message
> news:72FBD92B-A5E3-488D-8E60-56C6A36B48AA@.microsoft.com...
> > How do you change the collation on the master and temp DB
> >
> > Thanks
> > Anthony
>
>

Changing the server collations SQL 2005 Express

How do you change the collation on the master and temp DB
Thanks
AnthonyHello,
As far as I know you cant change the collation of system databases directly.
To do this you may need to rebuild the master database.
http://support.microsoft.com/?kbid=325335#7
Thanks
Hari
"Anthony" <Anthony@.discussions.microsoft.com> wrote in message
news:72FBD92B-A5E3-488D-8E60-56C6A36B48AA@.microsoft.com...
> How do you change the collation on the master and temp DB
> Thanks
> Anthony|||Thanks for the reply.
but this is for sql 2005 not 2000. It is not done in the same way.
"Hari Prasad" wrote:

> Hello,
> As far as I know you cant change the collation of system databases directl
y.
> To do this you may need to rebuild the master database.
> http://support.microsoft.com/?kbid=325335#7
> Thanks
> Hari
>
> "Anthony" <Anthony@.discussions.microsoft.com> wrote in message
> news:72FBD92B-A5E3-488D-8E60-56C6A36B48AA@.microsoft.com...
>
>

Thursday, March 22, 2012

Changing the collation

Dear gurus,
I am pursuing for a statement or function which allow me change the
collation at database level.
Thanks in advance and regards,
Enrichi enric,
I think you can change collation on database level using "alter database
collate command "
ALTER DATABASE database
{ ADD FILE < filespec > [ ,...n ] [ TO FILEGROUP filegroup_name ]
| ADD LOG FILE < filespec > [ ,...n ]
| REMOVE FILE logical_file_name
| ADD FILEGROUP filegroup_name
| REMOVE FILEGROUP filegroup_name
| MODIFY FILE < filespec >
| MODIFY NAME = new_dbname
| MODIFY FILEGROUP filegroup_name {filegroup_property | NAME =
new_filegroup_name }
| SET < optionspec > [ ,...n ] [ WITH < termination > ]
| COLLATE < collation_name >
}
thanks,
Jose de Jesus Jr. Mcp,Mcdba
MCP #2324787
"Enric" wrote:

> Dear gurus,
> I am pursuing for a statement or function which allow me change the
> collation at database level.
> Thanks in advance and regards,
> Enric|||Yes, but that will not change collation for the existing tables. For that, y
ou need to do ALTER
TABLE ... ALTER COLUMN for each table and each column in the database. And i
t also require you to
drop indexes (and probably a few more things). Not fun...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jose G. de Jesus Jr MCP, MCDBA" <Email me> wrote in message
news:2CA8C84A-C24A-4F58-8860-4C3F3D454037@.microsoft.com...
> hi enric,
> I think you can change collation on database level using "alter database
> collate command "
>
> ALTER DATABASE database
> { ADD FILE < filespec > [ ,...n ] [ TO FILEGROUP filegroup_name ]
> | ADD LOG FILE < filespec > [ ,...n ]
> | REMOVE FILE logical_file_name
> | ADD FILEGROUP filegroup_name
> | REMOVE FILEGROUP filegroup_name
> | MODIFY FILE < filespec >
> | MODIFY NAME = new_dbname
> | MODIFY FILEGROUP filegroup_name {filegroup_property | NAME =
> new_filegroup_name }
> | SET < optionspec > [ ,...n ] [ WITH < termination > ]
> | COLLATE < collation_name >
> }
> --
> thanks,
> --
> Jose de Jesus Jr. Mcp,Mcdba
> MCP #2324787
>
> "Enric" wrote:
>

Monday, March 19, 2012

Changing SQL Server Collation

Hi
Has anyone successfully changed the Collation type for a single user
database without having to use Rebuildm.exe and/or the ALTER DATABASE
statement as I`ve tried the latter and if there are CK`s you cannot.
Thanks in advance.
Sad guy
Using ALTER DATABASE only changes the default collation for that database.
To fully change the collation you'd have to alter every column, every
character-based user-defined type, and possibly other objects (I can't
remember offhand). The easiest method I've come up with for changing the
collation is:
A) Script the entire database using Enterprise Manager
B) Edit the script and change all of the collation designators to whatever
you want
C) Create a new database using the script
D) Use DTS to transfer the data out of the old database and into the new
database
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"ANON" <ANON@.discussions.microsoft.com> wrote in message
news:EFB1A3D2-6E98-4C81-82D1-2FF10EAC7BBF@.microsoft.com...
> Hi
> Has anyone successfully changed the Collation type for a single user
> database without having to use Rebuildm.exe and/or the ALTER DATABASE
> statement as I`ve tried the latter and if there are CK`s you cannot.
> Thanks in advance.
> Sad guy
|||Hi
Once a tables are created in a DB, ALTER DATABASE does not change those
column's collations.
What are you trying to do?
Regards
Mike
"ANON" wrote:

> Hi
> Has anyone successfully changed the Collation type for a single user
> database without having to use Rebuildm.exe and/or the ALTER DATABASE
> statement as I`ve tried the latter and if there are CK`s you cannot.
> Thanks in advance.
> Sad guy

Changing SQL Server Collation

Hi
Has anyone successfully changed the Collation type for a single user
database without having to use Rebuildm.exe and/or the ALTER DATABASE
statement as I`ve tried the latter and if there are CK`s you cannot.
Thanks in advance.
Sad guyUsing ALTER DATABASE only changes the default collation for that database.
To fully change the collation you'd have to alter every column, every
character-based user-defined type, and possibly other objects (I can't
remember offhand). The easiest method I've come up with for changing the
collation is:
A) Script the entire database using Enterprise Manager
B) Edit the script and change all of the collation designators to whatever
you want
C) Create a new database using the script
D) Use DTS to transfer the data out of the old database and into the new
database
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"ANON" <ANON@.discussions.microsoft.com> wrote in message
news:EFB1A3D2-6E98-4C81-82D1-2FF10EAC7BBF@.microsoft.com...
> Hi
> Has anyone successfully changed the Collation type for a single user
> database without having to use Rebuildm.exe and/or the ALTER DATABASE
> statement as I`ve tried the latter and if there are CK`s you cannot.
> Thanks in advance.
> Sad guy|||Hi
Once a tables are created in a DB, ALTER DATABASE does not change those
column's collations.
What are you trying to do?
Regards
Mike
"ANON" wrote:

> Hi
> Has anyone successfully changed the Collation type for a single user
> database without having to use Rebuildm.exe and/or the ALTER DATABASE
> statement as I`ve tried the latter and if there are CK`s you cannot.
> Thanks in advance.
> Sad guy

Changing SQL Server Collation

Hi
Has anyone successfully changed the Collation type for a single user
database without having to use Rebuildm.exe and/or the ALTER DATABASE
statement as I`ve tried the latter and if there are CK`s you cannot.
Thanks in advance.
Sad guyUsing ALTER DATABASE only changes the default collation for that database.
To fully change the collation you'd have to alter every column, every
character-based user-defined type, and possibly other objects (I can't
remember offhand). The easiest method I've come up with for changing the
collation is:
A) Script the entire database using Enterprise Manager
B) Edit the script and change all of the collation designators to whatever
you want
C) Create a new database using the script
D) Use DTS to transfer the data out of the old database and into the new
database
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"ANON" <ANON@.discussions.microsoft.com> wrote in message
news:EFB1A3D2-6E98-4C81-82D1-2FF10EAC7BBF@.microsoft.com...
> Hi
> Has anyone successfully changed the Collation type for a single user
> database without having to use Rebuildm.exe and/or the ALTER DATABASE
> statement as I`ve tried the latter and if there are CK`s you cannot.
> Thanks in advance.
> Sad guy|||Hi
Once a tables are created in a DB, ALTER DATABASE does not change those
column's collations.
What are you trying to do?
Regards
Mike
"ANON" wrote:
> Hi
> Has anyone successfully changed the Collation type for a single user
> database without having to use Rebuildm.exe and/or the ALTER DATABASE
> statement as I`ve tried the latter and if there are CK`s you cannot.
> Thanks in advance.
> Sad guy

Changing SQL Database Collation

Hello All,
I have a SQL Server database and the collation is set to "SQL_Latin1_General_CI_AI" and I need to change this to the SQL Server default. How do I change this?
ThanksYou will have to alter the database and the table/columns. Refer to the following article:

link (http://www.databasejournal.com/features/mssql/article.php/2013741)|||This is great! Thank you very much, appreciate the help.|||Again, thanks for the help, I just have one more question......
I have been playing around with the ALTER TABLE command in the article and I can change the collation to any collation name - The other databases have a blank collation, since they were created using "Server Default" I assume. I am unable to change the collation to "Server Default", and I am not sure what my server default is. I looked through SQL Server settings, but maybe I am missing something. Can I be directed to how I can determine what the collation name is for the server default? Hope this makes sense.
Thanks|||Right-click on your instance in enterprise manager and click properties. Under the general tab you will see the server collation.|||Thanks...I checked this and the collation is blank. What does this mean?|||Originally posted by m3122
Thanks...I checked this and the collation is blank. What does this mean?

In Query Analyser select the database node, right click and select Script to new window for CREATE. This should generate the full SQL create script for the database including it's specific collation.

If you have data in the database that needs recollating you have to remove all indexes, statistics and constraints that reference the collatable fields, ALTER the individual tables, ALTER the database and reapply all the removed entities. I put a two-stage script that will do this about a month ago.

http://www.dbforums.com/showthread.php?threadid=926370&highlight=hanafih|||Thanks for the reply. This worked fine. Thanks again.

Sunday, March 11, 2012

Changing Servers Collation

Personally I would go for the first, as its the bol
recommendation.
Out of curiousity have you thought of going down the
unicode route ?
J

>--Original Message--
>I am considering two solutions for changing the collation
on a Server, the first is to follow the advise of BOL and
script all the user DB's, export the data to text files or
another media and having deleted these databases from the
server use the Rebuildm.exe utility to reinstall the
Master database with the new collation. Then run the
scripts to recreate the DB's and import the data back in
>The second is to script the dropping and re-creation of
all indexes and keys and then change the column collations
using the following script to generate the alter table
statements required and then change the database
collation. Once this is done I can detach the user
databases and use the Rebuildm.exe utility, then I simply
re-attach the DB's.
>I have 75 user databases on the Server in question, any
suggestions on which method would be better.
>many thanks
>Ed
>select x =
> case so.xtype
> when 'u' then 'alter table ' + so.name
+ ' alter column ' + sc.name + ' ' + st.name + '('
> + cast(sc.length as varchar(5))
+ ') COLLATE Latin1_General_CI_AS;'
> END
>from syscolumns sc, sysobjects so, systypes st
>where so.id = sc.id
>and sc.xtype = st.xusertype
>and so.xtype = 'u'
>and so.name <> 'dtproperties'
>and st.xusertype in (175, 239, 99, 231, 35, 167)
>and sc.collation = 'SQL_Latin1_General_CP1_CI_AS'
>.
>Unfortunatly I have inherited a large number of databases with tables that h
ave a row width coming close to or excreding the 8000 charcter limit and yes
I have tried repeatedly to get this sorted out by normalising the tables bu
t its not to be.

Changing Servers Collation

Personally I would go for the first, as its the bol
recommendation.
Out of curiousity have you thought of going down the
unicode route ?
J

>--Original Message--
>I am considering two solutions for changing the collation
on a Server, the first is to follow the advise of BOL and
script all the user DB's, export the data to text files or
another media and having deleted these databases from the
server use the Rebuildm.exe utility to reinstall the
Master database with the new collation. Then run the
scripts to recreate the DB's and import the data back in
>The second is to script the dropping and re-creation of
all indexes and keys and then change the column collations
using the following script to generate the alter table
statements required and then change the database
collation. Once this is done I can detach the user
databases and use the Rebuildm.exe utility, then I simply
re-attach the DB's.
>I have 75 user databases on the Server in question, any
suggestions on which method would be better.
>many thanks
>Ed
>select x =
>case so.xtype
>when 'u' then 'alter table ' + so.name
+ ' alter column ' + sc.name + ' ' + st.name + '('
>+ cast(sc.length as varchar(5))
+ ') COLLATE Latin1_General_CI_AS;'
>END
>from syscolumns sc, sysobjects so, systypes st
>where so.id = sc.id
>and sc.xtype = st.xusertype
>and so.xtype = 'u'
>and so.name <> 'dtproperties'
>and st.xusertype in (175, 239, 99, 231, 35, 167)
>and sc.collation = 'SQL_Latin1_General_CP1_CI_AS'
>.
>
Unfortunatly I have inherited a large number of databases with tables that have a row width coming close to or excreding the 8000 charcter limit and yes I have tried repeatedly to get this sorted out by normalising the tables but its not to be.

Changing Servers Collation

I am considering two solutions for changing the collation on a Server, the first is to follow the advise of BOL and script all the user DB's, export the data to text files or another media and having deleted these databases from the server use the Rebuildm.exe utility to reinstall the Master database with the new collation. Then run the scripts to recreate the DB's and import the data back i
The second is to script the dropping and re-creation of all indexes and keys and then change the column collations using the following script to generate the alter table statements required and then change the database collation. Once this is done I can detach the user databases and use the Rebuildm.exe utility, then I simply re-attach the DB's
I have 75 user databases on the Server in question, any suggestions on which method would be better
many thank
E
select x
case so.xtype
when 'u' then 'alter table ' + so.name + ' alter column ' + sc.name + ' ' + st.name + '(
+ cast(sc.length as varchar(5)) + ') COLLATE Latin1_General_CI_AS;
EN
from syscolumns sc, sysobjects so, systypes s
where so.id = sc.i
and sc.xtype = st.xusertyp
and so.xtype = 'u
and so.name <> 'dtproperties
and st.xusertype in (175, 239, 99, 231, 35, 167
and sc.collation = 'SQL_Latin1_General_CP1_CI_AS'Personally I would go for the first, as its the bol
recommendation.
Out of curiousity have you thought of going down the
unicode route ?
J
>--Original Message--
>I am considering two solutions for changing the collation
on a Server, the first is to follow the advise of BOL and
script all the user DB's, export the data to text files or
another media and having deleted these databases from the
server use the Rebuildm.exe utility to reinstall the
Master database with the new collation. Then run the
scripts to recreate the DB's and import the data back in
>The second is to script the dropping and re-creation of
all indexes and keys and then change the column collations
using the following script to generate the alter table
statements required and then change the database
collation. Once this is done I can detach the user
databases and use the Rebuildm.exe utility, then I simply
re-attach the DB's.
>I have 75 user databases on the Server in question, any
suggestions on which method would be better.
>many thanks
>Ed
>select x => case so.xtype
> when 'u' then 'alter table ' + so.name
+ ' alter column ' + sc.name + ' ' + st.name + '('
> + cast(sc.length as varchar(5))
+ ') COLLATE Latin1_General_CI_AS;'
> END
>from syscolumns sc, sysobjects so, systypes st
>where so.id = sc.id
>and sc.xtype = st.xusertype
>and so.xtype = 'u'
>and so.name <> 'dtproperties'
>and st.xusertype in (175, 239, 99, 231, 35, 167)
>and sc.collation = 'SQL_Latin1_General_CP1_CI_AS'
>.
>|||Unfortunatly I have inherited a large number of databases with tables that have a row width coming close to or excreding the 8000 charcter limit and yes I have tried repeatedly to get this sorted out by normalising the tables but its not to be

Changing server collation

Hello there
I've tried to change collation of my server using rebuildm
It gave me an error: Rebuild master failed with error: -1
The database was created succeffuly, but the collation hasn't changed.
where can be the problem?
Roy
In that case I'd resinstall server
You change a collation per database/table/column
SELECT
'ALTER TABLE ' + TABLE_NAME +
' ALTER COLUMN ' + COLUMN_NAME +
' ' + DATA_TYPE +' '+
CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL
THEN '('+(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH)+')' )
ELSE isnull(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH),' ')
END
+' COLLATE Put here your colation '+
CASE IS_NULLABLE
WHEN 'YES' THEN 'NULL'
WHEN 'No' THEN 'NOT NULL'
END
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar')
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:u$jxwQFQGHA.3256@.TK2MSFTNGP15.phx.gbl...
> Hello there
> I've tried to change collation of my server using rebuildm
> It gave me an error: Rebuild master failed with error: -1
> The database was created succeffuly, but the collation hasn't changed.
> where can be the problem?
>
|||Hi Roy
To add to Uri's post, if rebuildm does not work first time I usually resort
to re-installing as the time to run rebuildm twice is probably more than a
full install.
You may want to set the new collation to default rather than a specific one,
this will pick up the database collation (so change it first). Using '[' and
']' around your object names may also be necessary.
You may also want to check out other posts such as http://tinyurl.com/429qa
John
"Roy Goldhammer" wrote:

> Hello there
> I've tried to change collation of my server using rebuildm
> It gave me an error: Rebuild master failed with error: -1
> The database was created succeffuly, but the collation hasn't changed.
> where can be the problem?
>
>
|||Whell Uri
This procedure has errors due to collation conflict, which it was suppose to
fix.
I've solved it, but it doesn't work if the column has index, constraint or
primary key.
The only way to solve it, is or by changing it with EM if the amount of
cases is realy small, or use generate databases script, and on the query
anlyser remove all the collations.
Is there better way to do this?
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23ncWUmFQGHA.2628@.TK2MSFTNGP15.phx.gbl...
> Roy
> In that case I'd resinstall server
> You change a collation per database/table/column
> SELECT
> 'ALTER TABLE ' + TABLE_NAME +
> ' ALTER COLUMN ' + COLUMN_NAME +
> ' ' + DATA_TYPE +' '+
> CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL
> THEN '('+(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH)+')' )
> ELSE isnull(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH),' ')
> END
> +' COLLATE Put here your colation '+
> CASE IS_NULLABLE
> WHEN 'YES' THEN 'NULL'
> WHEN 'No' THEN 'NOT NULL'
> END
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar')
>
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:u$jxwQFQGHA.3256@.TK2MSFTNGP15.phx.gbl...
>
|||Hi Roy
If you profiled what EM was doing you would probably see that it droped
constraints and indexes before issing the same statement. If your source code
is in version control this would not be a big issue. You could use DMO or EM
to script these or the INFORMATION_SCHEMA.KEY_COLUMN_USAGE and sysindexes
tables to generate a script using T-SQL.
John
"Roy Goldhammer" wrote:

> Whell Uri
> This procedure has errors due to collation conflict, which it was suppose to
> fix.
> I've solved it, but it doesn't work if the column has index, constraint or
> primary key.
> The only way to solve it, is or by changing it with EM if the amount of
> cases is realy small, or use generate databases script, and on the query
> anlyser remove all the collations.
> Is there better way to do this?
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23ncWUmFQGHA.2628@.TK2MSFTNGP15.phx.gbl...
>
>

Changing server collation

Hello there
I've tried to change collation of my server using rebuildm
It gave me an error: Rebuild master failed with error: -1
The database was created succeffuly, but the collation hasn't changed.
where can be the problem?Roy
In that case I'd resinstall server
You change a collation per database/table/column
SELECT
'ALTER TABLE ' + TABLE_NAME +
' ALTER COLUMN ' + COLUMN_NAME +
' ' + DATA_TYPE +' '+
CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL
THEN '('+(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH)+')' )
ELSE isnull(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH),' ')
END
+' COLLATE Put here your colation '+
CASE IS_NULLABLE
WHEN 'YES' THEN 'NULL'
WHEN 'No' THEN 'NOT NULL'
END
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar')
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:u$jxwQFQGHA.3256@.TK2MSFTNGP15.phx.gbl...
> Hello there
> I've tried to change collation of my server using rebuildm
> It gave me an error: Rebuild master failed with error: -1
> The database was created succeffuly, but the collation hasn't changed.
> where can be the problem?
>|||Hi Roy
To add to Uri's post, if rebuildm does not work first time I usually resort
to re-installing as the time to run rebuildm twice is probably more than a
full install.
You may want to set the new collation to default rather than a specific one,
this will pick up the database collation (so change it first). Using '[' and
']' around your object names may also be necessary.
You may also want to check out other posts such as http://tinyurl.com/429qa
John
"Roy Goldhammer" wrote:
> Hello there
> I've tried to change collation of my server using rebuildm
> It gave me an error: Rebuild master failed with error: -1
> The database was created succeffuly, but the collation hasn't changed.
> where can be the problem?
>
>|||Whell Uri
This procedure has errors due to collation conflict, which it was suppose to
fix.
I've solved it, but it doesn't work if the column has index, constraint or
primary key.
The only way to solve it, is or by changing it with EM if the amount of
cases is realy small, or use generate databases script, and on the query
anlyser remove all the collations.
Is there better way to do this?
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23ncWUmFQGHA.2628@.TK2MSFTNGP15.phx.gbl...
> Roy
> In that case I'd resinstall server
> You change a collation per database/table/column
> SELECT
> 'ALTER TABLE ' + TABLE_NAME +
> ' ALTER COLUMN ' + COLUMN_NAME +
> ' ' + DATA_TYPE +' '+
> CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL
> THEN '('+(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH)+')' )
> ELSE isnull(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH),' ')
> END
> +' COLLATE Put here your colation '+
> CASE IS_NULLABLE
> WHEN 'YES' THEN 'NULL'
> WHEN 'No' THEN 'NOT NULL'
> END
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar')
>
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:u$jxwQFQGHA.3256@.TK2MSFTNGP15.phx.gbl...
>> Hello there
>> I've tried to change collation of my server using rebuildm
>> It gave me an error: Rebuild master failed with error: -1
>> The database was created succeffuly, but the collation hasn't changed.
>> where can be the problem?
>|||Hi Roy
If you profiled what EM was doing you would probably see that it droped
constraints and indexes before issing the same statement. If your source code
is in version control this would not be a big issue. You could use DMO or EM
to script these or the INFORMATION_SCHEMA.KEY_COLUMN_USAGE and sysindexes
tables to generate a script using T-SQL.
John
"Roy Goldhammer" wrote:
> Whell Uri
> This procedure has errors due to collation conflict, which it was suppose to
> fix.
> I've solved it, but it doesn't work if the column has index, constraint or
> primary key.
> The only way to solve it, is or by changing it with EM if the amount of
> cases is realy small, or use generate databases script, and on the query
> anlyser remove all the collations.
> Is there better way to do this?
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23ncWUmFQGHA.2628@.TK2MSFTNGP15.phx.gbl...
> > Roy
> > In that case I'd resinstall server
> > You change a collation per database/table/column
> >
> > SELECT
> > 'ALTER TABLE ' + TABLE_NAME +
> > ' ALTER COLUMN ' + COLUMN_NAME +
> > ' ' + DATA_TYPE +' '+
> > CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL
> > THEN '('+(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH)+')' )
> > ELSE isnull(CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH),' ')
> > END
> > +' COLLATE Put here your colation '+
> > CASE IS_NULLABLE
> > WHEN 'YES' THEN 'NULL'
> > WHEN 'No' THEN 'NOT NULL'
> > END
> >
> > FROM INFORMATION_SCHEMA.COLUMNS
> > WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar')
> >
> >
> >
> > "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> > news:u$jxwQFQGHA.3256@.TK2MSFTNGP15.phx.gbl...
> >> Hello there
> >>
> >> I've tried to change collation of my server using rebuildm
> >>
> >> It gave me an error: Rebuild master failed with error: -1
> >>
> >> The database was created succeffuly, but the collation hasn't changed.
> >>
> >> where can be the problem?
> >>
> >
> >
>
>

Changing server collation

Hello there
I've tried to change collation of my server using rebuildm
It gave me an error: Rebuild master failed with error: -1
The database was created succeffuly, but the collation hasn't changed.
where can be the problem?Roy
In that case I'd resinstall server
You change a collation per database/table/column
SELECT
'ALTER TABLE ' + TABLE_NAME +
' ALTER COLUMN ' + COLUMN_NAME +
' ' + DATA_TYPE +' '+
CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL
THEN '('+(CONVERT(VARCHAR,CHARACTER_MAXIMUM_L
ENGTH)+')' )
ELSE isnull(CONVERT(VARCHAR,CHARACTER_MAXIMUM
_LENGTH),' ')
END
+' COLLATE Put here your colation '+
CASE IS_NULLABLE
WHEN 'YES' THEN 'NULL'
WHEN 'No' THEN 'NOT NULL'
END
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar')
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:u$jxwQFQGHA.3256@.TK2MSFTNGP15.phx.gbl...
> Hello there
> I've tried to change collation of my server using rebuildm
> It gave me an error: Rebuild master failed with error: -1
> The database was created succeffuly, but the collation hasn't changed.
> where can be the problem?
>|||Hi Roy
To add to Uri's post, if rebuildm does not work first time I usually resort
to re-installing as the time to run rebuildm twice is probably more than a
full install.
You may want to set the new collation to default rather than a specific one,
this will pick up the database collation (so change it first). Using '['
and
']' around your object names may also be necessary.
You may also want to check out other posts such as http://tinyurl.com/429qa
John
"Roy Goldhammer" wrote:

> Hello there
> I've tried to change collation of my server using rebuildm
> It gave me an error: Rebuild master failed with error: -1
> The database was created succeffuly, but the collation hasn't changed.
> where can be the problem?
>
>|||Whell Uri
This procedure has errors due to collation conflict, which it was suppose to
fix.
I've solved it, but it doesn't work if the column has index, constraint or
primary key.
The only way to solve it, is or by changing it with EM if the amount of
cases is realy small, or use generate databases script, and on the query
anlyser remove all the collations.
Is there better way to do this?
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23ncWUmFQGHA.2628@.TK2MSFTNGP15.phx.gbl...
> Roy
> In that case I'd resinstall server
> You change a collation per database/table/column
> SELECT
> 'ALTER TABLE ' + TABLE_NAME +
> ' ALTER COLUMN ' + COLUMN_NAME +
> ' ' + DATA_TYPE +' '+
> CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL
> THEN '('+(CONVERT(VARCHAR,CHARACTER_MAXIMUM_L
ENGTH)+')' )
> ELSE isnull(CONVERT(VARCHAR,CHARACTER_MAXIMUM
_LENGTH),' ')
> END
> +' COLLATE Put here your colation '+
> CASE IS_NULLABLE
> WHEN 'YES' THEN 'NULL'
> WHEN 'No' THEN 'NOT NULL'
> END
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE DATA_TYPE IN ('varchar' ,'char','nvarchar','nchar')
>
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:u$jxwQFQGHA.3256@.TK2MSFTNGP15.phx.gbl...
>|||Hi Roy
If you profiled what EM was doing you would probably see that it droped
constraints and indexes before issing the same statement. If your source cod
e
is in version control this would not be a big issue. You could use DMO or EM
to script these or the INFORMATION_SCHEMA.KEY_COLUMN_USAGE and sysindexes
tables to generate a script using T-SQL.
John
"Roy Goldhammer" wrote:

> Whell Uri
> This procedure has errors due to collation conflict, which it was suppose
to
> fix.
> I've solved it, but it doesn't work if the column has index, constraint or
> primary key.
> The only way to solve it, is or by changing it with EM if the amount of
> cases is realy small, or use generate databases script, and on the query
> anlyser remove all the collations.
> Is there better way to do this?
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:%23ncWUmFQGHA.2628@.TK2MSFTNGP15.phx.gbl...
>
>

Saturday, February 25, 2012

Changing MSDB Collation

I support an applicatoin where the vendor requires the use of the LATIN_1_GENERAL_BIN sort collation in their user databases. Origionally, when I installed the instance, I did not select this sort collation for the instance. I have since gone back and reinstalled SQL Server with the correct sort collation. After that, I restored the vendors databases from backups I took prior to reinstalling the instnace and they retained the LATIN_1_GENERAL_BIN collation (the correct one).

I also restored the MSDB database to get all of my jobs back. When I did this, MSDB took the old sort collation (SQL_LATIN_1_GENERAL_CPI_CI_AS). MSDB is the only database that has this collation and I'm getting errors in the agent log complaining of collation conflicts. I'm pretty sure the fact that the MSDB sort collation is different that all the other databases is the thing that's causing these error messages.

My question is this: Is there any way to change the sort collation of MSDB without reinstalling SQL server? This is a clustered environment and everytime I've reloaded SQL, it's been cumbersome and taken me at least 1 day's work.

Also, I know there's a rebuild master utility that will rebuild master, model and MSDB, but when I tried that last time it failed and I had to reinstall SQL anyway. Does anyone know of a way around this or have any tips on using the rebuildmaster utility in a clustered environment?

Many thanks,I've never tried this, and would STRONGLY urge you to make a backup before you try it.

You can change the default colation for a database using ALTER DATABASE (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_aa-az_4e5h.asp). You can use DBCC REINDEX (http://msdn.microsoft.com/library/en-us/tsqlref/ts_dbcc_94mw.asp) to rebuild the indicies (to use the new collation).

My gut feeling is that this should work, but let me stress again: Don't try this without at least two good backups!

-PatP|||Thanks Pat, but I already tried this (after taking good backups) and it didn't work. SQL 2000 won't let you alter the collation of MSDB.

I've been doing some researching and I actually think I'm going to try to use the rebuild master utility again. I've found an article in TechNet that gives better instructions than the ones I had before.

Thanks for the input.

Originally posted by Pat Phelan
I've never tried this, and would STRONGLY urge you to make a backup before you try it.

You can change the default colation for a database using ALTER DATABASE (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_aa-az_4e5h.asp). You can use DBCC REINDEX (http://msdn.microsoft.com/library/en-us/tsqlref/ts_dbcc_94mw.asp) to rebuild the indicies (to use the new collation).

My gut feeling is that this should work, but let me stress again: Don't try this without at least two good backups!

-PatP|||Rebuild master utility is the only tool availble to affect any changes after the installation.

By default master's collation will be affected to remaining system databases.|||See, I learned something today. Now I can go home!

-PatP

Friday, February 10, 2012

Changing database collation problem in SQL Server 2000

Hello...

When I migrated data from one SQL Server to another I got collection problems because collation of the target server was different from the source one.

The best solution I thought about was to change collation of the database in target server to be equal to the server collation so that when a temporary table is created, and the collation used would be the server collation, no error would occur. All sounds logic, but, after I ran ALTER DATABASE command and changed the collation of the database, I verified that all varchar fields of all database tables retained the old collation, not the new database collation I set.

Is there any way to change the collation of all fields at once when I change the database collation?

Thanks for your help

Jaime

All that happens when you execute the ALTER DATABASE statement is that you set the NEW default for any NEW tables.

If you want to change the existing tables, you will have have to change each (n)varchar and text column -one at a time.

ALTER TABLE MyTable

ALTER COLUMN MyColumn COLLATE NewCollation

Changing database collation

I need to copy a database from one server to another. In the process of
copying the database I would like to change the collation from
Latin1_General_Bin to SQL_Latin1_General_CP1_CI_AS.
I have tried using the SSIS Export Wizard but it had difficulty in
transfering views and would not copy any stored procedures. I then tried
Restoring a backup of the source database onto the destingation database. I
tried using the "alter database statement" to change the collation but this
failed due to dependencies on the database collation.
Is there a good method for copying a database and changing the collation?
Loren,
I have never personally done this so perhaps there is room for some
conjecture...
I would start with a logical method.
1. In SSIS I would use the Transfer database wizard which gives me source
and destination.
2. The next step of the SSIS package would be an execute SQL task and I
would Execute the Alter database command with the collate option.
Collate
http://technet.microsoft.com/en-us/library/ms184391.aspx
Alter Database
http://msdn2.microsoft.com/en-us/library/aa275464(SQL.80).aspx
Hope that helps...
/*
Warren Brunk - MCITP,MCTS,MCDBA
www.techintsolutions.com
*/
"Loren Z" <anonymous@.discussions.microsoft.com> wrote in message
news:%23OXTd8kTIHA.4360@.TK2MSFTNGP06.phx.gbl...
>I need to copy a database from one server to another. In the process of
>copying the database I would like to change the collation from
>Latin1_General_Bin to SQL_Latin1_General_CP1_CI_AS.
> I have tried using the SSIS Export Wizard but it had difficulty in
> transfering views and would not copy any stored procedures. I then tried
> Restoring a backup of the source database onto the destingation database.
> I tried using the "alter database statement" to change the collation but
> this failed due to dependencies on the database collation.
> Is there a good method for copying a database and changing the collation?
>
|||I see what you are saying...
"You can change the collation of any new objects that are created in a user
database by using the COLLATE clause of the ALTER DATABASE statement. This
statement does not change the collation of the columns in any existing
user-defined tables. These can be changed by using the COLLATE clause of
ALTER TABLE. "

/*
Warren Brunk - MCITP,MCTS,MCDBA
www.techintsolutions.com
*/
<GuilleSQL> wrote in message news:eohI5$mTIHA.4696@.TK2MSFTNGP05.phx.gbl...
> Hi Loren
> There is no method to change the collation to an existing SQL Server
> database. Using ALTER DATABASE, you can only chage the default collation,
> used to create new object, but existing objects maintain the previous
> collation.
> http://technet.microsoft.com/en-us/library/ms175835.aspx
> Try to create a new database, using the desired collation, and create the
> schema using the desired collation again. Then, you can populate tables
> from your source database using SSIS.
> Regards,
> GuilleSQL
> http://www.guillesql.es
>
> "Loren Z" <anonymous@.discussions.microsoft.com> wrote in message
> news:%23OXTd8kTIHA.4360@.TK2MSFTNGP06.phx.gbl...
>
|||Use a scripting tool like Redgate SQL Compare to generate scripts for your
existing database objects. You could do it using the free 14 day trial then
show your boss how much time(money) it saved and get him or her to buy it.
Create your new database with the collation set as you want it and then
build your tables, stored procedures views etc. from your script. You can
now run SSIS to transfer data from one database to another - although in
this particular case, if it is a one off, not a regular job, T-SQL bulk
insert may be quicker and easier.
Nigel Ainscoe
"Loren Z" <anonymous@.discussions.microsoft.com> wrote in message
news:%23OXTd8kTIHA.4360@.TK2MSFTNGP06.phx.gbl...
>I need to copy a database from one server to another. In the process of
>copying the database I would like to change the collation from
>Latin1_General_Bin to SQL_Latin1_General_CP1_CI_AS.
> I have tried using the SSIS Export Wizard but it had difficulty in
> transfering views and would not copy any stored procedures. I then tried
> Restoring a backup of the source database onto the destingation database.
> I tried using the "alter database statement" to change the collation but
> this failed due to dependencies on the database collation.
> Is there a good method for copying a database and changing the collation?
>