开发者

How to escape parenthesis in SQL query?

Using Microsoft SQL Server 2005 - wondering how can I escape parenthesis in my query?

I'm trying to find the string position of "(" in one of my columns returned, but Management Studio keeps thinking I'm opening another command when I use that. I've tried \ but that 开发者_如何学Pythonisn't escaping it.

Thank you!


this doesn't work for you?

select charindex('(', yourColumn)
from yourTable


You don't need to escape it, see example below:

select charindex('(', x)
from (
    select 'asdasda(adsadas' as x
) a

Output:

8


select charindex('(',<columnname>) from <tableName>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜