UPDATE DB4010.dbo.EntityStagedData
SET
EntityData = (
SELECT
geo.City + ' ' + geo.Description + ' ' + geo.Street + ' ' +
geo2.City + ' ' + geo2.Description + ' ' + geo2.Street
FROM DB4010.dbo.RouteTemplates templates
INNER JOIN DB4010.dbo.RouteTemplateClients clients
ON clients.RouteTemplateID = templates.RouteTemplateID
INNER JOIN DB4010.dbo.RouteTemplateStopMasters masters
ON masters.RouteTemplateClientID = clients.RouteTemplateClientID
INNER JOIN DB4010.dbo.RouteTemplateStopDetails details
ON details.RouteTemplateStopID = masters.PickupStopID
INNER JOIN DB4010.dbo.RouteTemplateStopDetails details2
ON details2.RouteTemplateStopID = masters.DeliveryStopID
INNER JOIN DB4010.dbo.Geofences geo
ON geo.GeofenceID = details.GeofenceID
INNER JOIN DB4010.dbo.Geofences geo2
ON geo2.GeofenceID = details2.GeofenceID
WHERE clients.RouteTemplateID = DB4010.dbo.EntityStagedData.EntityID
)
WHERE EXISTS (SELECT RouteTemplateID FROM DB4010.dbo.RouteTemplates)
這是給我的錯誤:更新選擇
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'EntityData', table 'DB4010.dbo.EntityStagedData'; column does not allow nulls. UPDATE fails.
我不能,我的生活,找出如何從結果更新+串聯「EntityData」內Select語句...
不知道我理解你所說的「從內Select語句的結果‘’更新+串聯」 EntityData意味着你是什麼意思添加「實體數據」到選擇的結果,或添加EntityData對結果的現有值,還是別的? – Bort
那麼,EntityData會從內部select語句中追加NVARCHAR響應... – MatBee