Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 [Resolved]Update to trim values

Author  Topic 

dan_coder
Starting Member

20 Posts

Posted - 2006-08-04 : 04:51:33
Hi guys.

I have to update a field of a table replacing all valus with same values without spaces at start and at the end. In visual basic I should use

UPDATE table_name SET field_name=trim(field_name)

How to in SQLServer?

Thanks!

Q
Yak Posting Veteran

76 Posts

Posted - 2006-08-04 : 04:58:12
use LTRIM and RTRIM instead of trim
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-08-04 : 04:58:36
UPDATE table_name
SET field_name=LTrim(RTrim(field_name))
WHERE field_name <> LTrim(RTrim(field_name))

Kristen
Go to Top of Page

dan_coder
Starting Member

20 Posts

Posted - 2006-08-04 : 05:12:53
tks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-04 : 09:45:37
quote:
Originally posted by dan_coder

tks


It seems you trimmed non spaces also

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -