1

我正在尝试将 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 语句,验证每一列都有一个名称

4

1 回答 1

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

为列命名,以便它可以用于创建新表。

于 2014-09-04T15:45:50.280 回答