none
how to identify a database is unicode?

    Question

  • Hello everyone,

    i did  a search about this topic and had reached than 

    Unicode data uses NCHAR / NVARCHAR / NTEXT datatypes rather than CHAR /
    VARCHAR / TEXT. This is defined at the column level rather than the database
    level.

    is there any way to determine if a sqlserver database is unicode data? i mean at the dbproperties ...etc. 

    thanks..


    evgeni
    Wednesday, September 07, 2011 6:55 AM

Answers

  • if exists
    (
    select ordinal_position 'Seq',
           cast(column_name as varchar(40)) 'Column',
           isnull(character_maximum_length, numeric_precision) 'Size',
           cast(data_type   as varchar(12)) 'Type'
    from   information_schema.columns
    where cast(data_type   as varchar(12)) IN ('nchar','nvarchar')
    )
    print 'db is unicode'
    else
    print 'no unicode'

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    • Marked as answer by evgenixristov Wednesday, September 07, 2011 7:57 AM
    Wednesday, September 07, 2011 7:50 AM
    Answerer

All replies

  • if exists
    (
    select ordinal_position 'Seq',
           cast(column_name as varchar(40)) 'Column',
           isnull(character_maximum_length, numeric_precision) 'Size',
           cast(data_type   as varchar(12)) 'Type'
    from   information_schema.columns
    where cast(data_type   as varchar(12)) IN ('nchar','nvarchar')
    )
    print 'db is unicode'
    else
    print 'no unicode'

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    • Marked as answer by evgenixristov Wednesday, September 07, 2011 7:57 AM
    Wednesday, September 07, 2011 7:50 AM
    Answerer
  • Thanks  Uri Dimant .this is what i was looking for..

     


    evgeni
    Wednesday, September 07, 2011 7:58 AM
  • You can't say that a database "is in Unicode" or not. Whether to use Unicode is not a selection made at the database level, it is an attribute defined at the column level, by chosing what datatype to use. Uri's script will say "db is in unicode" if you have one column which is ncharchar or char, but you can have any mix and match between Unicode and non-Unicode columns as you wish...
    Tibor Karaszi, SQL Server MVP | web | blog
    Wednesday, September 07, 2011 9:18 AM