-2
Update PSSFAAssets

Set PSSFAAssets.ProjectID = xhh_quickscan.ProjectID,
    PSSFAAssets.CpnyAssetNo = xhh_quickscan.Barcode,
    PSSFAAssets.CustomDate01 = xhh_quickscan.Date1,
    PSSFAAssets.CustomDate02 = xhh_quickscan.Date2,
    PSSFAAssets.CustomDate03 = xhh_quickscan.Date3,
    PSSFAAssets.CustomDate00 = xhh_quickscan.Date4,
    PSSFAAssets.SerialNo = xhh_quickscan.Serial,
    PSSFAAssets.Custom10Char02 = xhh_quickscan.AStatus,
    PSSFAAssets.CustomDate04 = xhh_quickscan.Scandate
From
  (select * from xhh_quickscan 
  where crtdate  > '8/17/2013 7:55 AM'
  and crtdate  <= '8/18/2013 2:37 PM')

ON PSSFAAssets.AssetID = xhh_quickscan.AssetID

抛出错误:“关键字'ON'附近的语法不正确。”
为“ON”尝试了子“WHERE”;没运气。

4

3 回答 3

2

为什么不更简单?子查询对我来说似乎是多余的。

UPDATE p
SET ProjectID      = s.ProjectID,
    CpnyAssetNo    = s.Barcode,
    CustomDate01   = s.Date1,
    CustomDate02   = s.Date2,
    CustomDate03   = s.Date3,
    CustomDate00   = s.Date4,
    SerialNo       = s.Serial,
    Custom10Char02 = s.AStatus,
    CustomDate04   = s.Scandate
FROM dbo.PSSFAAssets AS p
INNER JOIN dbo.xhh_quickscan AS s
ON p.AssetID = s.AssetID
WHERE s.crtdate >  '20130817 07:55'
  AND s.crtdate <= '20130818 14:37';
于 2013-08-20T20:43:45.947 回答
1

这是SQL Server 上UPDATEwith a的正确语法:JOIN

UPDATE A
SET A.ProjectID = B.ProjectID,
    A.CpnyAssetNo = B.Barcode,
    A.CustomDate01 = B.Date1,
    A.CustomDate02 = B.Date2,
    A.CustomDate03 = B.Date3,
    A.CustomDate00 = B.Date4,
    A.SerialNo = B.Serial,
    A.Custom10Char02 = B.AStatus,
    A.CustomDate04 = B.Scandate
FROM PSSFAAssets A
INNER JOIN (SELECT * 
            FROM xhh_quickscan 
            WHERE crtdate  > '8/17/2013 7:55 AM'
            AND crtdate  <= '8/18/2013 2:37 PM') B
ON A.AssetID = B.AssetID
于 2013-08-20T20:10:05.167 回答
0

这将是最好的方法。

Update PSSFAAssets
Set PSSFAAssets.ProjectID = xhh_quickscan.ProjectID,
    PSSFAAssets.CpnyAssetNo = xhh_quickscan.Barcode,
    PSSFAAssets.CustomDate01 = xhh_quickscan.Date1,
    PSSFAAssets.CustomDate02 = xhh_quickscan.Date2,
    PSSFAAssets.CustomDate03 = xhh_quickscan.Date3,
    PSSFAAssets.CustomDate00 = xhh_quickscan.Date4,
    PSSFAAssets.SerialNo = xhh_quickscan.Serial,
    PSSFAAssets.Custom10Char02 = xhh_quickscan.AStatus,
    PSSFAAssets.CustomDate04 = xhh_quickscan.Scandate
From xhh_quickscan 
where xhh_quickscan.crtdate  > '8/17/2013 7:55 AM'
  and xhh_quickscan.crtdate  <= '8/18/2013 2:37 PM'
  and PSSFAAssets.AssetID = xhh_quickscan.AssetID
于 2013-08-20T21:34:12.017 回答