Groups | Blog | Home
all groups > sql server new users > may 2006 >

sql server new users : Convertin Text -> Nvarchar


Carlos Albert
5/23/2006 6:55:52 PM
Hello group,

I have to convert some strings that I had on a Text field to Nvarchar. I
don't care if some data gets lost.
I tried this, but doesn't work because it's too long and complains about it:

UPDATE mytable

SET mynVarChar= cast(myInfo as nvarchar(4000))

Carlos Albert
5/24/2006 12:00:00 AM
Hello Hugo. First of anything, thanks for your answer.

Yes, mynvarchar is an existing field, declared as nvarchar(4000)...

[quoted text, click to view]

Hugo Kornelis
5/24/2006 12:13:57 AM
[quoted text, click to view]

Hi Carlos,

Is the column "mynVarChar" declared as nvarchar(4000) ???

I could not reproduce this - until I tried what would happen if the
column mynVarChar is shorter than 4000 positions.

You can't just use nvarchar without explicit length in the CREATE TABLE
statement, since the length will default to 1 in that case!

--
Hugo Kornelis
5/24/2006 11:23:41 PM
[quoted text, click to view]

Hi Carlos,

Since I was unable to reproduce this, I'd like to see the table
structure (as CREATE TABLE statement, including all constraints,
properties, and indexes), some rows of sample data (as INSERT
statemetns), and the *exact* text of both your query and the error
message you are getting (please use cut and paste to prevent typos).

Soo www.aspfaq.com/5006 for some advice on assembling CREATE TABLE and
INSERT statements.

--
AddThis Social Bookmark Button