SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Characters are changing after an alter table alter column executed?


Characters are changing after an alter table alter column executed?

Author
Message
Thinky Night
Thinky Night
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1429 Visits: 321
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...
Luis Cazares
Luis Cazares
SSC Guru
SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)

Group: General Forum Members
Points: 172730 Visits: 23044
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
Lowell
Lowell
SSC Guru
SSC Guru (307K reputation)SSC Guru (307K reputation)SSC Guru (307K reputation)SSC Guru (307K reputation)SSC Guru (307K reputation)SSC Guru (307K reputation)SSC Guru (307K reputation)SSC Guru (307K reputation)

Group: General Forum Members
Points: 307620 Visits: 42366
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!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search