OptimisticYid
08-19-2008, 02:27 AM
Just a quick problem .... I hope. I'm using SQL Server Management Express to administer my SQL database. Basically I have about 1100 products, 400 of which have a postage price of £6.00 which I need to change to £4.95, but the SQL statement I have written below doesn't seem to work. Can anyone point out 'the error of my ways'.
Update LS2Products
Set ProductPostagePrice = replace(ProductPostagePrice, '6.0000', '4.9500')
Many thanks in advance.
SQL_Hell
08-19-2008, 02:46 AM
Hi there
Replace is a string function and is used for replacing part of a text based column, so for example say we have a column called 'text1' which contains
"I like beer"
If you wanted to change to wine then you would use replace
Replace(text1,'beer','wine')
What you need is the following:
Update LS2Products
Set ProductPostagePrice = '4.9500'
Where ProductPostagePrice = '6.0000'
OptimisticYid
08-19-2008, 02:57 AM
Why would I ever want to replace wine with beer :D If you know Al Murray you will know that it is wine and fruit based drinks 'for the ladies'.
Many thanks for your quick answer though, worked a treat ;)
SQL_Hell
08-19-2008, 03:13 AM
lol, please accept my apologees I didn't mean to suggest that you will be undergoing a sex change ;) :D
But seriously no probs for the code, glad I was able to help :)