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
 General SQL Server Forums
 New to SQL Server Programming
 replace problem

Author  Topic 

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-04-23 : 14:12:44
Hi.I have a column wich has to be stripped.

I wrote a query like this:
UPDATE tbl_product3
SET product_stripped = REPLACE(product_name, ' ', '-')

it works fine.but the problem is if the space is at the beginning of the product_name I dont want to replace '-' at the beginning of the product_stripped.

what sould I do to have the correct results.

" 170 caps" the result is "-170-caps" but I want "170-caps"(no - at the beginning)
thanks


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-23 : 14:15:38
UPDATE tbl_product3
SET product_stripped = REPLACE(LTRIM(product_name), ' ', '-')
Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-04-23 : 14:19:42
thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-23 : 14:23:04
UPDATE tbl_product3
SET product_stripped = REPLACE(ltrim(rtrim(product_name)), ' ', '-')


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -