【发布时间】:2021-02-04 11:54:56
【问题描述】:
我们正在使用 node-mssql 包插入和读取我们的 azure mssql 数据库。 数据库非常简单,因为它只是用作键/值缓存,其中值可以很长,并且还包含特殊字符。
数据库架构:
create table cache
(
id int identity
constraint cache_pk
primary key nonclustered,
cacheKey varchar(500),
ttl bigint,
value varchar(max)
)
go
create index cache_cacheKey_index
on cache (cacheKey desc)
go
create index cache_ttl_index
on cache (ttl)
go
由于某种原因,当我在“值”中插入值时,一些特殊字符没有得到很好的处理。
Dash – example
变成:
Dash example
我看到法国撇号也发生了同样的事情。
我也尝试过更改排序规则,但这并没有帮助。
还尝试使用nvarchar(max) 作为列类型。
这是插入代码(包括sql):
const result = await conn.request()
.input('key', mssql.VarChar, key)
.input('value', mssql.Text, value)
.input('ttl', mssql.BigInt, cacheEndTime)
.query`INSERT INTO cache (cacheKey, value, ttl) VALUES (@key, @value, @ttl)`;
能否请您提供正确的表结构或 sql 语句来完成这项工作?
【问题讨论】:
-
该值没有问题,因此这表明您有一些东西在某处剥夺了该值。文字
INSERT工作正常:db<>fiddle
标签: sql-server azure azure-sql-database node-mssql