characters encoding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Krzysiek

    characters encoding

    Hello,

    in what code-page are characters stored in MSSQL tables?
    is it windows1250?

    --
    Chris
  • Dan Guzman

    #2
    Re: characters encoding

    You can determine the instance default collation with SERVERPROPERTY:

    SELECT SERVERPROPERTY( 'Collation')

    Collation can be specified at the column, database or instance level. If
    not specified when the column is created, the database default collation is
    used. If no database collation is specified, then the instance collation is
    used.

    It is best to use the default instance collation unless you have a specific
    reason to do otherwise.

    --
    Hope this helps.

    Dan Guzman
    SQL Server MVP

    "Krzysiek" <stefanetNOSPAM @nospam.o2.pl> wrote in message
    news:cu2nrl$331 $1@news.onet.pl ...[color=blue]
    > Hello,
    >
    > in what code-page are characters stored in MSSQL tables?
    > is it windows1250?
    >
    > --
    > Chris[/color]


    Comment

    • Erland Sommarskog

      #3
      Re: characters encoding

      Krzysiek (stefanetNOSPAM @nospam.o2.pl) writes:[color=blue]
      > in what code-page are characters stored in MSSQL tables?
      > is it windows1250?[/color]

      Text data can be stored in two ways in SQL Server: nchar/nvarchar/ntext
      which is Unicode, and char/varchar/text which is some 8-bit encoding.

      With Unicode datatypes you don't have to bother all characters are there.

      With 8-bit datatypes they will be in some code page. And, yes, in your
      case this could well be 1250, since this is the code page normally used
      for Polish.

      SQL Server have a concept of collations, and as Dan said there is a default
      collation on server level, and there is also a default on database level.
      But the actual collation can vary from column to column.

      As Dan said, to get the default server collation, you can say:

      SELECT SERVERPROPERTY( 'Collation')

      To get the default collation for a database, you can do:

      select databasepropert yex(db_name(), 'Collation')

      And to see the collations for the columns in a table, use sp_help.

      Once you have the collation, you can say:

      select collationproper ty('Collationna me', 'CodePage')

      to find the code page.

      --
      Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

      Books Online for SQL Server SP3 at
      Transform your business with a unified data platform. SQL Server 2019 comes with Apache Spark and Hadoop Distributed File System (HDFS) for intelligence over all your data.

      Comment

      Working...