ansi to unicode (data conversion)

ansi to unicode (data conversion)

Post by cHJhdmVlb » Sat, 20 Dec 2003 23:06:11


There is a requirement for me to convert ansi data into Japanese code page ...

I have one logic to do this as follows .

/*********************************************************************
CREATE FUNCTION dbo.ansi2uni_fn (@AnsiStr varchar(8000)
RETURNS nvarchar(4000
A
BEGI
DECLARE @nonUniJap TABLE (AnsiStr varchar(8000) COLLATE Japanese_CI_AS
INSERT INTO @nonUniJap SELECT convert(varbinary(8000), @AnsiStr
SELECT @UniStr = (SELECT AnsiStr FROM @nonUniJap
RETURN @UniStr
END
/*********************************************************************

This works fine, the problem is i need to update 3 million records using this function, which is dead slow

So, is there any way using CAST/CONVERT with out user defined function so that it could be faster

Thank
 
 
 

ansi to unicode (data conversion)

Post by Sm9yZ2UgTG » Sat, 20 Dec 2003 23:31:20

Hi.

Can this help you.

CAST('abcde' AS varchar(5)) COLLATE Japanese_CI_AS

 
 
 

ansi to unicode (data conversion)

Post by bart » Sun, 21 Dec 2003 01:24:09

It your situation that you have code page 932 (Japanese) data stored in a
code page 1252 (Latin1) column? If so, I know of no way to do the change
"in place" other than the approach you outlined. However, it might be
faster to BCP out and BCP back in.

1. Back up the db
2. BCP the data out with the -CRAW command line param
3. Drop and recreate the table/column with the appropriate collation
(Japanese_CI_AS)
4. BCP back in with command line param -C932

------------
Bart Duncan
Microsoft SQL Server Support

Please reply to the newsgroup only - thanks.
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
Thread-Topic: ansi to unicode (data conversion)
thread-index: AcPGPMUvuDemMv2pT126CNDiXvkdSQ==
X-Tomcat-NG: microsoft.public.sqlserver.programming
From: =?Utf-8?B?Sm9yZ2UgTGF2YWRv?= < XXXX@XXXXX.COM >
References: < XXXX@XXXXX.COM >
Subject: RE: ansi to unicode (data conversion)
Date: Fri, 19 Dec 2003 06:31:20 -0800
Lines: 5
Message-ID: < XXXX@XXXXX.COM >
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.sqlserver.programming
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.sqlserver.programming:411138
X-Tomcat-NG: microsoft.public.sqlserver.programming

Hi.

Can this help you.

CAST('abcde' AS varchar(5)) COLLATE Japanese_CI_AS