change the Unicode datatype NVarchar to Varchar

  • is there any way to change the Unicode datatype NVarchar to Varchar?

  • varchar is not Unicode.

    You can change the data type, but any unicode data would be lost or cause errors during the conversion. Only the N data types (ntext, nvarchar, nchar) accept Unicode data.

  • I know that varchar is using ASCII. And just want to know if there is way for conversion because using cast is not correct. Thanks!

  • Why CAST is not correct?

    _____________
    Code for TallyGenerator

  • use cast will result in ???

  • CAST is not a translater. Meaning if you have a Japanese kanji character in Unicode, SQL Server has no way to CAST that to varchar. You're asking to somehow translate two bytes into one and there are no rules for that.

    If you store a "ABC" in Unicode (NVARCHAR) and CAST that to VARCHAR, it will work because the top byte is all zeros. CAST works. If there is data from a non-ASCII character set in the upper byte, you CANNOT cast it.

    CAST works fine if you are storing ASCII characters in the Nvarchar and just want to change the column type.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply