[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Contained Database Collations

Posted on 2016-11-19
6
Medium Priority
?
42 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 10

Expert Comment

by:Jason clark
ID: 41895331
0
 
LVL 52

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 52

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 52

Accepted Solution

by:
Vitor Montalvão earned 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 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