T-SQL Collation Conflict

T-SQL Collation Conflict thumbnail
Multiple collations on data can cause conflicts.

A collation in SQL Server decides how character strings are stored in databases. A conflict can arise when you use temporary tables in your database application and the collation of the database does not match that of the temporary table.

  1. Collation

    • A collation is a specification for the manner in which characters are physically stored, that is, the bit-patterns that represent each character. It also specifies the sorting and ordering rules for character strings.

    Specifying Collations

    • Collation can be specified at the database, table and also the column level, that is, for a field in a table. Each column in a table can have a different collation.

    Collation Conflict

    • If you use temporary tables as a means of temporary workspace in T-SQL procedures, you have to pay attention to collations. If the default collation of the temporary table does not match that of the database or its tables, SQL Server gives an error message indicating a collation conflict.

    Resolving Collation Conflicts

    • Whenever you need a temporary table in T-SQL code, either create the table with the default database collation or use the "COLLATE" command when inserting into, updating and referencing the table. The default collation for the current database can be specified by the keyword "database_default" in the "COLLATE" command. As an alternative, use a separate SQL Server instance for each distinct collation.

    Finding Available Collations

    • Execute this T-SQL query for the names of collations supported by the SQL Server instance:

      select * from ::fn_helpcollations()

Related Searches:

References

Resources

  • Photo Credit business report image by Christopher Hall from Fotolia.com

Comments

You May Also Like

  • How to Change a Collation Name

    Collation is a database clause that you define using Structured Query Language (SQL) commands. It tells the database what character set it...

  • SQL Date Conflict Check

    The Structured Query Language (SQL) is used to add, modify and retrieve (query) data from a database. The SQL language includes a...

  • How to Install MS SQL Server

    Microsoft SQL Server is a relational database management server (RDBMS). Its primary query language is Transact-SQL, a version of the ANSI/ISO standard....

  • How to Determine if a Temporary Table Exists in SQL Server

    When writing a stored procedure, sometimes it is helpful to be able to find out if a temporary table already exists. Amongst...

  • How to Collate

    Collating is arranging a number of pages in a specific order, such as in books or reports. Collating can often be done...

  • How to Collate a Tax Return

    If you are filing a paper tax return this year, there is a specific order that the IRS generally wants you to...

  • How to Collate Survey Results

    While the Internet offers many online survey options, sometimes you need to use a good, old-fashioned written survey. They are easy to...

  • How to Find a Software Conflict

    Software conflicts occur where two or more programs running concurrently on your computer are incompatible, leading to onscreen errors and potential system...

  • How to Make a Primary Key Case Sensitive

    You establish a primary key in a database as a field that provides unique identification for each row of data. By default,...

  • How to Update Multiple Columns From Another Table

    SQL, or Structured Query Language, is a standard language many relational database management systems use to work with the data stored in...

Related Ads

Featured