Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Converting EBCDIC to ASCII

Author  Topic 

jdoering
Starting Member

32 Posts

Posted - 2003-06-24 : 08:30:58
Does anyone know if it is possible to convert EBCDIC data to ASCII data using SQL Server? Is there a SQL Server Function or script to do this?

Thanks,
Julie

nr
SQLTeam MVY

12543 Posts

Posted - 2003-06-24 : 10:25:04
Depends a bit on what the data looks like - do you have in in a string or binary?

Create a table with the mappings between the two character sets then either
go through each byte in the string replacing it
or
go through each character in the mapping table doing a replace on the string


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2003-06-24 : 12:59:30
quote:

go through each character in the mapping table doing a replace on the string


If you do this, you have to be very careful of the order you translate them, otherwise some characters will get translated multiple times.


Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2003-06-24 : 13:49:39
Isn't it a straight 8 bit byte to 8 bit byte translation?

How can some characters get translated more than once?

Sam

Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2003-06-24 : 15:58:34
I thought Nigel was suggesting that it could -- effectively be done with a giant nested replace like:
REPLACE(... REPLACE(REPLACE(column, CHAR(193), CHAR(65)), CHAR(194), CHAR(66))..., CHAR(249), CHAR(57))
(I'm not sure it was a serious suggestion!)
But if you translate the string this way, you have to avoid one of your REPLACEs changing something that was the result of an earlier (more nested) REPLACE. If there are loops in translation (x -> y -> z -> x) then you need to use a temporary value. If it's a permutation of all 256 characters, you can't use this approach.


Edited by - Arnold Fribble on 06/24/2003 16:00:32
Go to Top of Page
   

- Advertisement -