tags:

views:

435

answers:

2

Could someone please help me with this?

I need to convert an nchar column to an nvarchar column and trim the whitespace.

Thank you.

+2  A: 
SELECT RTrim(CAST([MynCharColumn] As nVarChar))
Joel Coehoorn
You need to give a length for nvarchar, else you can truncate the data (defaults to 30 if not specified like this!)
AdaTheDev
To do that, I'd need to know the length of the nChar column.
Joel Coehoorn
I see. Thank you very much.
Joe Flateau
+4  A: 
declare @foo nchar(32)
select @foo = '   Hello, World   '
select ltrim(rtrim(convert(nvarchar(32), @foo)))
Adamski