sql - 使用带引号转义的 unicode N 前缀
问题描述
我有一个问题,我需要将 select 语句作为值存储在数据库中的字段中,以便 Web 服务稍后执行它并在不同的应用程序中显示结果。
当我使用表中的 select 语句更新值时转义单引号,我失去了 unicodeN
前缀功能。
例子:
update table
set sqlstatement = 'select No as N''Ī'' from table'
where ID = 1
N
执行保存的SQL语句时,列名返回为'I'而不是'Ī' 使用前缀时有什么特殊的方法可以转义单引号吗?
解决方案
将 N 添加到 'select No as N''Ī'' from table' 的头部
declare @table as table(id int identity(1,1),sqlstatement nvarchar(100))
insert into @table values('select No as N''Ī'' from table')
--before
select sqlstatement from @table where Id=1
declare @sqlstatement as nvarchar(100)
update @table
set sqlstatement = N'select No as N''Ī'' from table'
where ID = 1
--After
select sqlstatement from @table where Id=1
推荐阅读
- django-models - 如何使用 django-filter 搜索 django restframework 中的所有内容
- python - 在主窗口显示弹出窗口?
- react-native - 如何升级 react-native 版本?
- angular - 为什么 Promise api 调用没有传递正确的数据元素?
- ios - #define 改变多参数方法名
- python - 在 groupby() Pandas 之后将 Multiindex 转换为单个索引
- c++ - 使用指针调用 C++ DLL 函数
- android - 卸载android应用程序不会删除文档目录中的文件
- javafx - 如何在 javafx 中使用@FXML?
- c# - GetComponent 无法将类型“Class”隐式转换为 GameController