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.
| Author |
Topic |
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2008-08-15 : 10:17:37
|
| Hi All,I have a Table called Product with the following fields.UPC nvarchar(12)Category nvarchar(50)SubCategory nvarchar(50)Department nvarchar(50)Brand nvarchar(50)In my select I want to return everything (all columns) but if there's any pipe | character in the Brand column I want to replace that character with a empty character. Following is an example.Let suppose the following 3 records exists (records are seperated by comma). Please notice the Brand records.UPC,Category,SubCategory,Department,Brand012345678901,012477,477,9876,Pepsi| Lime01236518901,023570,570,67000,Kellogs|| Essential||987449236,987210,7210,8855,Bacardi Si|lver |My select should return the following.UPC,Category,SubCategory,Department,Brand012345678901,012477,477,9876,Pepsi Lime01236518901,023570,570,67000,Kellogs Essential987449236,987210,7210,8855,Bacardi Si lverHow can I do this?Please help.Thanks a million for your quick help.Zee |
|
|
cardgunner
326 Posts |
Posted - 2008-08-15 : 10:29:13
|
| Have you tried the replace functionreplace(yourtablename.Brand, '|', '')CardGunner |
 |
|
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2008-08-15 : 10:41:13
|
| Thanks cardgunner for your help.The following is working :) select ID, Brand, replace(Product.Brand, '|', '') Brand from product |
 |
|
|
|
|
|
|
|