如何将长 select 语句插入或更新到列中?

How to insert or update a long select statement into a coulmn?

所以我有这就是我想做的

我的表名称是 GameInvLoc,有 3 列 ID、GameLoc、GameInv

ID   GameLoc    GameInv
1    Bre        Null

我想这样做

Update GameInvLoc
   set GameInv = 'select 'ROlID,Whse,Company,LocationNo' union all select concat(id,',',Whse,',',Company,',',LocationNo) from CINT..vwGameReport' 
 where id = 1

但我对引文有疑问,我在引用时遇到语法错误。

有人知道正确的方法吗?

您必须使用两次单引号来表示字符串文字中的一个单引号。

像这样:

Update GameInvLoc
   set GameInv = 'select ''ROlID,Whse,Company,LocationNo'' union all select concat(id,'','',Whse,'','',Company,'','',LocationNo) from CINT..vwGameReport' 
 where id = 1