>Hi,
>
>How would I replace a portion of a field in a table with another string for all records that match some criteria?
>
>Let's say I have a SKU field that is "1234-xxxx" and I want to change the field to be "abcd-xxxx":
>
>
>update Orders set SKU = SKU.Replace("1234","abcd") where ProductID = 285
>
>
>Am I on the right track? I was expecting intellisense to show in Visual Studio 2003, but it doesn't.
>
>Thanks in advance,
>Paul
replace() changes all occurences. Use stuff() instead. ie:
Replace chars 1-4 with "abcd":
update Orders set SKU = stuff(SKU,1,4,'abcd') where ProductID = 285
Replace syntax would be:
update Orders set SKU = replace(SKU,'1234','abcd') where ProductID = 285
PS: Up to including SQL server 2000 T-SQL doesn't support method chaining like C#
SKU.Replace(...) not supoported IOW.
Replace(SKU,...)
Cetin