我今天在SQL Server(2008R2和2012)中遇到了一个非常奇怪的问题.我正在尝试使用串联和select语句来构建字符串.
我找到了解决方法,但我真的很想了解这里发生了什么以及为什么它没有给我预期的结果.有人可以向我解释一下吗?
http://sqlfiddle.com/#!6/7438a/1
根据要求,这里的代码也是:
-- base table
create table bla (
[id] int identity(1,1) primary key,
[priority] int,
[msg] nvarchar(max),
[autofix] bit
)
-- table without primary key on id column
create table bla2 (
[id] int identity(1,1),
[priority] int,
[msg] nvarchar(max),
[autofix] bit
)
-- table with nvarchar(1000) instead of max
create table bla3 (
[id] int identity(1,1) primary key,
[priority] int,
[msg] nvarchar(1000),
[autofix] bit
)
-- fill the three tables with the same values …Run Code Online (Sandbox Code Playgroud)