gpt4 book ai didi

SQL服务器: need to escape [?

转载 作者:行者123 更新时间:2023-12-02 15:35:10 25 4
gpt4 key购买 nike

我需要在 SQL Server 的 sql 查询中转义 [

select * from sometable where name like '[something]';

我实际上正在寻找某个东西之前的 [,但我不希望它像通配符一样。我尝试过:

select * from sometable where name like ''[something]';

但是从中得到错误消息:

Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'something'. Msg 105, Level 15, State 1, Line 1 Unclosed quotation mark after the character string ';

最佳答案

用途:

select * from sometable where name like '[[]something[]]';

您也可以使用:

select * from sometable where name like '\[something\]' escape '\';

描述于 LIKE (Transact-SQL) on MSDN .

关于SQL服务器: need to escape [?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8984380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com