How to insert into a derived table, & then select from the final result with Joins. Beginner level.
Posted on 2013-06-16
Hello, I'm trying to add data to a derived table and being new to MS SQL am confused by the correct syntax. Also my google searches are returning 0 results, so I'm not sure if I'm allowed to do what i'm attempting, though I can't see why not. The 2nd stage of this query is to then requery tblSupplierData for additional fields.
INSERT INTO derivedtbl_1 (fldSupplierId, fldItemCode)
SELECT (fldSupplierId, (fldItemCode)
WHERE (fldSupplierId = @supplierID) AND (fldIssueSequenceNumber = @sequenceNo)
(SELECT fldSupplierId, fldItemCode
WHERE (fldSupplierId = @supplierID) AND (fldSubscriptionId = @subscriptionId) AND (fldCustomerId = @customerID)) As derivedtbl_1