Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2005-04-05 : 11:47:44
|
| I need your help on using charindex or patindex or whatever functions to get the position of 2nd ' in a text string. The text string (column name where_clause) may looks like this:"head_order_nbr in ('q120120','q120210')"CHARINDEX('''',where_clause) will give me the position of first '.And because the data could also look next, so I cannot use (, =, or ,head_order_nbr in ('q120210')head_order_nbr='Q260396'I know it is a very bad db design,but I have to live with it.Thanks! |
|
|
rfrancisco
Yak Posting Veteran
95 Posts |
Posted - 2005-04-05 : 12:06:48
|
| Try this:CHARINDEX('''', where_clause, CHARINDEX('''', where_clause) + 1)Have you ever considered dynamic SQL to perform your task? |
 |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2005-04-05 : 12:21:02
|
| Thanks. It worked!I totally forgot there is a starting position in charindex.No, we have not try dynamic sql. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|