473,416 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Data being returned with upper ASCII chars changed!

!NoItAll
297 100+
I think I have the wrong collation set on a database I restored to a different server.
Somehow the data in a varbinary field (it's used to store a date) is being returned incorrectly.
Here's what I mean:
In the query analyzer the data shows up as:

0xDD3FC20120A42A940000000000000000

However with the following select statement:

Expand|Select|Wrap|Line Numbers
  1. select convert(char(8), itemdate) as mydate from item_data where itemid=12345678
  2.  
Instead of getting

<DD><3F><C2><01><20><A4><2A><94>

I get this mess

<A6><3F><2D><01><20><F1><2A><F6>

I think it has something to do with an incorrect collation setting because every character in the extended ASCII range (>7F) is returned translated. All of the characters in the lower ASCII range (01 to 7F) are returned properly.
The current Collation name is: SQL_Latin1_General_CP850_CI_AS
I think I need something that is designed for UTF8 - but I'm not sure...
If I do need to change the collation - how do I do that? I can't find a setting to change it.
Oct 11 '10 #1

✓ answered by !NoItAll

After further investigation I was right. Having the wrong collation was causing fields I was converting to char translated. Any char above 7F would get translated to the current collation set. When I restored the archive to my new machine it offered several collation options - clearly I chose the wrong one.
To fix this it is very easy.

I executed the following commands:

select * from ::fn_helpcollations()

This gave me a list of all the available collations. I chose a straight binary one - assuming no translation would take place with this in place.

Latin1_General_BIN

So I then executed the following command (available from SQL 2000 and up)

alter database [my_database] collate Latin1_General_BIN

Voila! I am now getting the chars untranslated and my calculations now produce the correct dates.

I found the following article via Google:

http://www.databasejournal.com/featu...-Collation.htm

1 1452
!NoItAll
297 100+
After further investigation I was right. Having the wrong collation was causing fields I was converting to char translated. Any char above 7F would get translated to the current collation set. When I restored the archive to my new machine it offered several collation options - clearly I chose the wrong one.
To fix this it is very easy.

I executed the following commands:

select * from ::fn_helpcollations()

This gave me a list of all the available collations. I chose a straight binary one - assuming no translation would take place with this in place.

Latin1_General_BIN

So I then executed the following command (available from SQL 2000 and up)

alter database [my_database] collate Latin1_General_BIN

Voila! I am now getting the chars untranslated and my calculations now produce the correct dates.

I found the following article via Google:

http://www.databasejournal.com/featu...-Collation.htm
Oct 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mike Jeffers | last post by:
Hi everyone, I need to convert data from a structure into hexadecimal ascii format. The structure is like this: struct ROOM_DATA { short room_number; short floor_number; long total_area;
3
by: James Pahiris | last post by:
Is there any way to store an extended ascii char in visual basic .net In previous VB chr$(254) ' â–  I need to send ascii chars (8 bit) to a serial port Thanks for any help.
5
by: Sean Kirkpatrick | last post by:
As part of my ongoing effort to provide a set of .Net wrappers for DAO, I'm writing a simple parser in VB.Net to search collection of VB6 source files to add explicit qualifiers to existing...
0
by: Nyrine | last post by:
Hi ! I have some external tables set up to load data into an oracle 9i database. My table is created as : create table XT405 ( . . XREF2 NVARCHAR2(50)
1
by: Hooyoo | last post by:
I read the content from a file encoded with UTF8 like this: byte data = binaryReader.ReadBytes(file.Length); And next step, I want to transform data to ASCII format, How can I do this? You...
5
by: TOXiC | last post by:
Hello everybody. How I can do a regex match in a string with ascii and non ascii chars for example: regex = re.compile(r"(ÿÿ‹ð…öÂty)", re.IGNORECASE) match =...
2
by: Sanders Kaufman | last post by:
I've noticed that some code analyzers comment that the type of data returned by my functions is "unknown" in the following syntax: function fnFooBar($aryParameters) { $bRetVal = True; return...
3
by: Learning.Net | last post by:
How to read a Unicode data saved as ASCII in notepad file as txt ? I tried using streamReader but it is not showing Unicode data. eg. using (StreamReader sr = new StreamReader(test.txt) {...
1
by: CSINVA | last post by:
I have a stored procedure that returns columns from a table called UserProfile. Within the table, it has a column called ProfielD, PropertyValue, Visitbility. I need to be able set the values...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.