Change datatype from nchar to nvarchar

Char and Nchar are fixed length data-types wich reserves the specified characters as storage space even if you entry don't use up that space.

Working with these data-types in code ( c-sharp ) for instance you will see strings with trailing withspaces if your entry don't use all the storage space of the column. Sometimes this handy to change the data-type to varchar or nvarchar to get rid of all the trailing whitespaces. Just changing the datatype will not remove all the whitespaces, to remove the whitespaces update all the colums with it's own value trimmed. Example of script which generate you SQL to update all the nvarchar columns:

select 'update ' + + ' set ' + + '=RTRIM(' + + ')' 
from syscolumns c, sysobjects o
where and c.xtype=231 and o.type='U' and = 'yourtablename'
order by,




Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!