Database.Collation Database.Collation Database.Collation Property

Definition

Gets or sets the default collation used by the database.

public:
 property System::String ^ Collation { System::String ^ get(); void set(System::String ^ value); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcProperty(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.Expensive | Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.Standalone | Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.SqlAzureDatabase | Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.Design, "SQL_Latin1_General_CP1_CI_AS")]
public string Collation { get; set; }
Public Property Collation As String
Property Value

A String value that specifies the name of the collation.

Implements

Examples

VB

'Connect to the local, default instance of SQL Server.  
Dim srv As Server  
srv = New Server  

'Reference the AdventureWorks2012 database.  
Dim db As Database  
db = srv.Databases("AdventureWorks2012")  

'Display the current default collation.  
Console.WriteLine(db.Collation)  

'Display the case-sensitivity of the current collation.  
Console.WriteLine("Collation is case-sensitive = " + _  
db.CaseSensitive.ToString)  

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database  
$db = $srv.Databases.Item("AdventureWorks2012")  
Write-Host "Collation is case-sensitive =" $db.CaseSensitive  

Remarks

You can find the available collation strings in Selecting a SQL Collation, by running the EnumCollations method, or during SQL Server setup. The collation string contains information about the code page, case-sensitivity, accent sensitivity, and language or alphabet.

Applies to