Sql – Trim trailing space from table contents

nvarcharsql servertrim

I have a table in a SQL server 2000 database with a nvarchar(30) field "details". There are some 10,000 records in that with a trailing space. I need a query to trim the particular field content in all rows. How can I achieve this?

Thanks.

Best Answer

UPDATE table SET details = RTRIM(details)

For padding, you could do, for instance:

UPDATE table SET details = details + '    '

or

UPDATE table SET details = '    ' + details