Characters are changing after an alter table alter column executed?

  • Hi dears,

    Some problems occured during an ALTER TABLE ALTER COLUMN statement.

    My SQL Server Instance Collation : SQL_Latin1_General_CP1_CI_AS
    My Database Collation: Turkish_CI_AS
    My Column Data Type: nvarchar(200)
    And change it to varchar(200)
    When I executed:
         ALTER TABLE myTable ALTER COLUMN  myColumn varchar(200); 

    My Turkish Characters went bad. After executed the DDL Statement, i checked the collation of the COLUMN: and it was TURKISH_CI_AS, also.

    How do i achieve this?

    Waiting your responses...

  • Thinky Night - Monday, February 11, 2019 10:52 PM

    Hi dears,

    Some problems occured during an ALTER TABLE ALTER COLUMN statement.

    My SQL Server Instance Collation : SQL_Latin1_General_CP1_CI_AS
    My Database Collation: Turkish_CI_AS
    My Column Data Type: nvarchar(200)
    And change it to varchar(200)
    When I executed:
         ALTER TABLE myTable ALTER COLUMN  myColumn varchar(200); 

    My Turkish Characters went bad. After executed the DDL Statement, i checked the collation of the COLUMN: and it was TURKISH_CI_AS, also.

    How do i achieve this?

    Waiting your responses...

    You altered the column and went from unicode to ascii. You limited the available characters for the column and in that process you lost the Turkish characters. If you need Unicode characters, you need to keep Unicode columns.
    There's no way to recover your data, unless you take it from a backup.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • restore the  table from a backup. you have permanently converted the previous data to bad data/question marks instead of retaining the original values.
    Turkish characters sets use  UNICODE, which plain old varchar does not support. varchar supports just plain old ascii characters.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

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