![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to convert this sample string: "Some like <X> better than <Y>. I like <Y> better than <X>, but my daughter prefers <X>." To this one: "Some like cats better than dogs. I like dogs better than cats, but my daughter prefers cats." Thus, <X> gets replaced with 'cats' and <Y> gets replaced with 'dogs'. (snip) I would much rather make a little table that had the variables and their values: (snip) Then, I would like to issue a statement that joins the phrase to the substitution tables and does the REPLACES for all variables without requiring lots of nesting. |
#3
| |||
| |||
|
|
If it's just the one phrase (in a variable), then this works on my database: SELECT @phrase_tx = REPLACE(@phrase_tx, variable_nm, variable_value_tx) FROM phrase_variable OPTION (MAXDOP 1); I'm not 100% sure if this is fully documented and supported though. |
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
|
The article describes the behavior of using ORDER BY as undefined. Even recommends the approach that Hugo used as workaround solution (of course, the query doesn't use ORDER BY): |
#7
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |