在sql中是否有一种方法可以声明一个没有固定长度的字符串类型,以便在具有固定长度的nvarchar字段上进行过滤?
例如,这就是我现在要做的事情 -
declare @input nvarchar(255)
set @input = 'test'
select * from table
where field = @input
这是我希望能够做到的事情 -
declare @input string
set @input = 'test'
select * from table
where field = @input
答案 0 :(得分:3)
只需将变量声明为nvarchar(4000)或nvarchar(max)。
对于可变长度字符串,字符串的长度不需要匹配才能进行比较。
固定长度字符串不是这样,但这完全是另一回事。