Hi I am trying to do an inner join on an alias that has additional text onto the value, how would i do this?
This is what i have tried and it doesn't work:
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
I assume you want to use PartNumber
from the SELECT
in the ON
clause. You need to repeat the expression . . . or use some similar trick:
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.