SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 [Resolved]Update to trim values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dan_coder
Starting Member

20 Posts

Posted - 08/04/2006 :  04:51:33  Show Profile  Click to see dan_coder's MSN Messenger address  Reply with Quote
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!

Edited by - dan_coder on 08/04/2006 05:13:43

Q
Yak Posting Veteran

Netherlands
76 Posts

Posted - 08/04/2006 :  04:58:12  Show Profile  Reply with Quote
use LTRIM and RTRIM instead of trim
Go to Top of Page

Kristen
Test

United Kingdom
22403 Posts

Posted - 08/04/2006 :  04:58:36  Show Profile  Reply with Quote
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 - 08/04/2006 :  05:12:53  Show Profile  Click to see dan_coder's MSN Messenger address  Reply with Quote
tks
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 08/04/2006 :  09:45:37  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000