开发者

Trim trailing space from table contents

开发者 https://www.devze.com 2022-12-13 10:11 出处:网络
I have a table in a SQL server 2000 database with a nvarchar(30) field \"details\". There are some 10,000 records in that wi开发者_StackOverflow社区th a trailing space. I need a query to trim the part

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

Thanks.


UPDATE table SET details = RTRIM(details)

For padding, you could do, for instance:

UPDATE table SET details = details + '    '

or

UPDATE table SET details = '    ' + details


If you wish to do this in a select statement only, use

SELECT RTRIM(Val)
FROM Table

If you wish to change the values in the table, use update

UPDATE Table
SET Val = RTRIM(Val)

For padding puposes you can use replicate

SELECT REPLICATE('*', 10) + 'TADA'
0

精彩评论

暂无评论...
验证码 换一张
取 消