我正在尝试将5个字符串变量连接到新表中的新字符串中。
SELECT [id],IsNull(Cast(x01 as nvarchar(4000)),'')
+ IsNull(Cast(x02 as nvarchar(4000)),'')
+ IsNull(Cast(x03 as nvarchar(4000)),'')
+ IsNull(Cast(x04 as nvarchar(4000)),'')
+ IsNull(Cast(x05 as nvarchar(4000)),'')
INTO newtable
FROM oldtable AS [id],[new_string];
我不理解产生的错误消息,因为我正在创建一个新表 - 如何丢失列名?我期待新表中的两个变量:id,new_string
对象或列名称缺失或为空。对于SELECT INTO语句,请验证每列是否具有名称
答案 0 :(得分:0)
SELECT [id],IsNull(Cast(x01 as nvarchar(4000)),'')
+ IsNull(Cast(x02 as nvarchar(4000)),'')
+ IsNull(Cast(x03 as nvarchar(4000)),'')
+ IsNull(Cast(x04 as nvarchar(4000)),'')
+ IsNull(Cast(x05 as nvarchar(4000)),'') as new_string
---------^^^^^^^^^^^^^
INTO newtable
FROM oldtable
为列命名,以便可以用它来创建新表。