osql converted characters during execution

August 30, 2006 at 1:05 pm Leave a comment

Suppose you have a sql script that inserts values into a MS SQL database. You had previous tested the script on the query analyzer, but when you ran the script in osql you notice that some of your characters have been converted. For example that soft hypen has mysteriously turned into a “û”.

Windows uses several different type of codepages. There is ANSI, which is used by windows and appears to be the default on SQL 2000 server. DOS uses OEM. There is also the Unicode format.

The problem is that when you run osql from the command line or from a cmd file, it automatically assumes that the file is in OEM format. If your file is in ANSI, it will convert the characters as if you are going from OEM to ANSI. This can cause some characters like a hypen to convert.

Solution is to save the file in Unicode. 

Advertisements

Entry filed under: MS SQL Server, Windows.

Recovery from a broken sudo Soft hyphen broken my XML – a warning about encoding

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

August 2006
M T W T F S S
« Jul   Sep »
 123456
78910111213
14151617181920
21222324252627
28293031  

Most Recent Posts


%d bloggers like this: