June 8, 2004 at 6:25 pm
how do I change "Pack of" to "Case of" in the following ?
SELECT NAME
FROM dbo.PRODUCT
WHERE (NAME LIKE '%pack of%')
------------------------------------------
Current Results
Beer (Pack of 12)
Gold Shoes (Pack of 12)
Hamburger (Pack of 12)
IceCream (Pack of 12)
------------------------------------------
Desired Results
Beer (Case of 12)
Gold Shoes (Case of 12)
Hamburger (Case of 12)
IceCream (Case of 12)
------------------------------------------
Options
1. SELECT REPLACE('abcdefghicde','cde','xxx')
2. Delete Pack, and then readd --> how can you delete part of a field ?
June 8, 2004 at 11:33 pm
Hello,
Try this query and check it out....
SELECT REPLACE(NAME, SUBSTRING(NAME, CHARINDEX('Pack', NAME), 4), 'Case') FROM dbo.Product WHERE (NAME LIKE '%pack of%')
Lucky
June 9, 2004 at 12:14 am
Options 1 and 2 represent two different approaches.
1) Keep the underlying data and modify the result.
2) Change the underlying data and just show the result.
The real question is: should the data say 'pack of' or 'case of' - which is correct?
If 'pack of' is good - then go for option 1)
If it should be 'case of' then it's option 2)
For 2) - no you don't delete part of a field, you update the whole field to the new value(s)
/Kenneth
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply