How to change Instance Collation of sql server running on amazon rds? - sql-server

I'm running SQL Server 2008R2 Standard edition on and RDS instance. I need to change the server's collation.So how can i change?

Based on documentation:
Amazon RDS creates a default server collation for character sets when
a SQL Server DB instance is created. This default server collation is
currently English (United States), or more precisely,
SQL_Latin1_General_CP1_CI_AS.
You can change the default collation at the database, table, or column level by overriding the collation when creating a new database or database object. For example, you can change from the default collation SQL_Latin1_General_CP1_CI_AS to Japanese_CI_AS for Japanese collation support. Even arguments in a query can be type-cast to use a different collation if necessary.
So change to desired collation on
database
ALTER DATABASE db_name
COLLATE collate_name;
column
ALTER TABLE dbo.table_name ALTER COLUMN col_name
type COLLATE collate_name;

Related

Microsoft SQL Server case sensitive queries

Is it possibile to have databae-wide settings to make sql queries case-sensitive on Microsoft SQL Server, e.g. 2012?
I'm refering to http://vyaskn.tripod.com/case_sensitive_search_in_sql_server.htm and it turn out for me that I can only modify queries to handle collations per column or to modify schema for specific columns have case-sensitive collations.
If I try
"ALTER DATABASE my_database COLLATE SQL_Latin1_General_CP1_CS_AS;"
it is not helping. Instead I have a problem with column names in my queries. I'm wonderign if there are separate settings for column name and data case-sensitivity for Ms SQL Server?

SQL server collation change on the instance level

When a database is created from our application, it takes the default Collation. we don't want to pass the collation in the create database script.
A client has a collation set on the instance level that is Case Sensitive. So the database created for our application is in that collation which is something we don't want.
Can they change the collation on the instance level so the database that gets created will have the desired collation and they can change it back to whatever they want? How do we do this on the instance level?
Thanks for your time!
So the problem is that the database is not created by a script run in, say, SQL Management Studio, but a script launched from within the application.
As noted in the comments and another answers changing the server collation is possible but hairy, the best option in a case like this is creating the database empty, changing the collation (either with ALTER DATABASE or from Management Studio), and then create the rest of the database.
This would require changing the application, but only the creation of the database itself since the tables will take the collation of the database, not the server collation (and you can do it in a way that works for every client, check if the database exists and that case skip DB creation and proceed with the rest of objects).
As a final warning, note that having a DB with a collation different of the server collation would mean than the DB has a different collation than the tempdb, so if you use temporal tables you would have problems if you have WHERE's or JOIN's mixing temporal and regular tables. For example, supposing that SerialNumber is a char column, this query will fail with a collation error:
SELECT *
FROM Products
JOIN #TempTable ON #TempTable.SerialNumber=Products.SerialNumber
If that case you will have to modify the application and change the queries to something like this:
SELECT *
FROM Products
JOIN #TempTable ON #TempTable.SerialNumber=Products.SerialNumber COLLATE database_default
You can configure the instance collation which would require dropping the databases before changing it. Here is a link to setting or changing the Server Collation.
You can also do this on a database level. Here is information on setting or changing collation on the database level.
You may also want to read the collation clause which can also be applied to tables, columns, and casting expressions among additional options.

Can user defined function change default server collation?

I`m using MSSQL Server 2014 for my web application where database collation is set to Latin1_General_CI_AS. In one of my queries I have problem with Turkish characters. Probably, problem occurs in user defined function which is called from query. So the question is, can collation of columns be changed if I for example alter table but not set any collation (I think that default DB collation should be set by default) change their type?

SQL Server: changing collation of selected columns

In SQL Server how to change a collation of only selected columns? Is there a way to do that using SQL Server Management Studio?
I was googling around but what I found where instructions how to change collation of a database not a specific column.
EDIT:
So I found this bit of SQL to change column's collation:
ALTER TABLE MyTable
ALTER COLUMN Column1 [TYPE] COLLATE [NewCollation]
Still is there a way to do that using SQL Server Management Studio?
Right-click on table name and choose Design. Then select column and go to Collation in column properties tab (inside Table Designer group).

SQL Server 2008 Case Sensitivity problem

My SQL Server query analyzer raises an error when I type my table names with lower-case letters.
My server and database collations are SQL_Latin1_General_CP1254_CI_AS.
Despite of it, Select * from table raises an error, while Select * From TABLE doesn't raise any error.
Where I am wrong? How can I make case-insensitive? I use SQL Server 2008
Give "select * from [table]" a try. And this is a silly question but is the name of the table, table?
Your server has a case insensitive collation, but each individual database may have its own collation. As it happens, this particular database has a case sensitive collation. If not explicitly specified (see CREATE DATABASE ... COLLATE ...) databases inherit the collation of the server they were originally created on. Likely this database was created on a server that had case sensitive collation and then attached/restored on your server.
the current database collation can be seen, for each database, in sys.databases:
select collation_name
from sys.databases
where database_id = db_id('...');

Resources