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 ' + o.name + ' set ' + c.name + '=RTRIM(' + c.name + ')' 
from syscolumns c, sysobjects o
where o.id=c.id and c.xtype=231 and o.type='U' and o.name = 'yourtablename'
order by o.name,c.name

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

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