2017-04-03 64 views
0

您好我正在嘗試做一個內部聯接的附加文本到值的別名,我會怎麼做?SQL如何在內部加入別名

這就是我試圖和它不工作:

INSERT INTO [dbo].[Inventory] ([VendorName], [PartNumber], [QuantityAvailable]) 
    SELECT 'TestVendor', 'V/P' + [Partnumber] as PartNumber, [QuantityAvailable] 
    FROM [dbo].[Bulk_Temp] 
    inner join v_PartMaster on Bulk_Temp.PartNumber = v_PartMaster.FullPartNumber 

回答

2

我假設你想要的ON子句中使用PartNumberSELECT。你需要重複這個表達。 。 。或使用一些類似的把戲:

INSERT INTO dbo.Inventory (VendorName, PartNumber, QuantityAvailable) 
    SELECT 'TestVendor', 'V/P' + Partnumber as PartNumber, QuantityAvailable 
    FROM dbo.Bulk_Temp JOIN 
     v_PartMaster 
     ON 'V/P' + PartNumber = v_PartMaster.FullPartNumber; 
+0

非常感謝你 –