Search This Blog

Monday, August 19, 2013

Something useful for myself

Replacing a string in MS SQL.

REPLACE(OriginalField, "OldString", "NewString")

SELECT REPLACE(LastName, "Smith", "OriginalSmith")

This would change all occurrences of Smith in the LastName field to OriginalSmith. Smith becomes OriginalSmith, O'Smith becomes O'OriginalSmith, smithey becomes OriginalSmithey, and so forth. Microsoft has this on their site, but sometimes their terminology is too technical when looking for a quick answer.

No comments:

Post a Comment