SQLServer转义下划线青少年心理辅导
本⽂翻译⾃:
How do I escape the underscore character? 如何转义下划线字符?
如何转义下划线字符?
I am writing something like the following where clau and want to be able to find actual entries with _d at the end. 我正在编
我正在编写类似以下where⼦句的内容,并希望能够在末尾找到_d的实际条⽬。
Where Urname Like '%_d'
#1楼
#2楼
Obviously @Las solution is right, but there's another way to solve your problem: T-SQL operator LIKE defines the optional clau, that lets you declare a character which will escape the next character
into the pattern. 显然,@ Las解决⽅案是正确
显然,@ Las解决⽅案是正确的,但是还有另⼀种解决问题的⽅法:T-SQL运算符LIKE定义了可选的⼦句,该⼦句使您可以声明⼀个字符,该字符将下⼀个字符转义到模式中。
For your ca, the following WHERE claus are equivalent: 对于您的情况,以下WHERE⼦句是等效的:
大学英语四级报名
对于您的情况,以下WHERE⼦句是等效的:
WHERE urname LIKE '%[_]d'; -- @Las solution
WHERE urname LIKE '%$_d' ESCAPE '$';
WHERE urname LIKE '%^_d' ESCAPE '^';
#3楼
简答题>toiletThe solutions totally make n. 这些解决⽅案完全有意义。
这些解决⽅案完全有意义。 Unfortunately, neither worked for me as expected. 不幸的是,
不幸的是,没有⼀个对我有⽤。 Instead of trying to hassle with it, I went with a work around: 我没有尝试⿇烦,⽽是进⾏了以下⼯作:香港教科书
我没有尝试⿇烦,⽽是进⾏了以下⼯作:
没有⼀个对我有⽤。
lect * from lumns
where replace(table_name,'_','!') not like '%!%'
order by table_name
#4楼
这对我有⽤,只需使⽤转义符'%\\_%'
gap是什么意思knowledge#5楼
noticed
None of the worked for me in SSIS v18.0, so I would up doing something like this: 这些都不适合我在SSIS v18.0中使⽤,
这些都不适合我在SSIS v18.0中使⽤,因此我会做这样的事情:
因此我会做这样的事情:
WHERE CHARINDEX('_', thingyourarching) < 1
..where I am trying to ignore strings with an underscore in them. ..在这⾥我试图忽略带有下划线的字符串。
..在这⾥我试图忽略带有下划线的字符串。 If you want to find things that have an underscore, just flip it around: 如果要查找带有下划线的内容,只需翻转⼀下即可:
如果要查找带有下划线的内容,只需翻转⼀下即可:
WHERE CHARINDEX('_', thingyourarching) > 0
#6楼
: ::
You can u the wildcard pattern matching characters as literal characters. 您可以将通配符模式匹配
的字符⽤作⽂字字
您可以将通配符模式匹配的字符⽤作⽂字字符。 To u a wildcard character as a literal character, enclo the wildcard character in brackets. 要将通配符⽤作⽂字外甥英文
要将通配符⽤作⽂字符。
字符,请将通配符括在⽅括号中。 The table shows veral examples of using the LIKE keyword and the [ ] wildcard 字符,请将通配符括在⽅括号中。裤子英语
characters. 下表显⽰了使⽤LIKE关键字和[]通配符的⼏个⽰例。
下表显⽰了使⽤LIKE关键字和[]通配符的⼏个⽰例。
For your ca: 对于您的情况:
对于您的情况:
... LIKE '%[_]d'