Solved

Contained Database Collations

Posted on 2016-11-19
6
29 Views
Last Modified: 2016-11-24
hi experts

i am Reading about Contained Database Collations, but i do not understand
Contained Database Collations
and
Collations of Tempdb
0
Comment
Question by:enrique_aeo
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Jason clark
ID: 41895331
0
 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 41895495
When a Contained database is created will get by default the same collation the SQL Server instance has so when you copy/move the Contained database to another SQL Server instance with another default collation it will keep the original collation so you just need to be aware of this and be careful when working with temporary tables since the last ones will have the default collation from the actual SQL Server instance and you might run in collation errors.
0
 

Author Comment

by:enrique_aeo
ID: 41896576
can you give me an example in T-SQL?
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 41897092
I'm not sure what kind of example are you looking for. This is like working with another regular database that has a different collation from the default so you'll need to explicitly convert to the necessary collation. In this case guarantee that you create the temporary objects with the same collation as the Contained Database:
CREATE TABLE #TempTable 
(
    Id INT,
    Name nvarchar(100) COLLATE Latin1_General_CI_AI
);  

Open in new window

0
 

Author Comment

by:enrique_aeo
ID: 41897727
This problem is solved with: CATALOG_DEFAULT?
0
 
LVL 47

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41898681
This problem is solved with: CATALOG_DEFAULT?
There are alternative ways to solve this. My example above is to use the same collation as the Contained Database.
If you want to use the SQL Server instance default collation then you'll need to do it in an opposite way. For example:
USE ContainedDB_name
GO

CREATE TABLE #TempTable 
(
    Id INT,
    Name nvarchar(100) 
);  

SELECT *
FROM MyTable
WHERE Name IN (SELECT Name COLLATE Default_Collation_Name
               FROM #TempTable);

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question