Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace a portion of a string
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Application:
Web
Miscellaneous
Thread ID:
01381814
Message ID:
01448389
Views:
44
>>>Within an update command, I need to replace a portion of a string in a Text field. So, basically, I am looking for the equivalent of this in SQL Server:
>>>
>>>
>>>UPDATE MyTable SET MyField=STRTRAN(MyField," \ ","\")
>>>
>>
>>REPLACE()
>>
>>
>>UPDATE MyTable SET MyField=REPLACE(MyField,' \ ','\')
>>
>
>How do you get this to work if your field name is description ?

Put the field into the brackets. [Description]
UPDATE MyTable SET [Description] =REPLACE([Description],' \ ','\')
If a field is SQL Server reserved word, you need to use []. You can use it for regular fields as well. In other words, you can use it every time.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform