I am trying to create a table in Database A from a table in database B. I have an idea with the query. In the database A, the table needs MerchantID and can get it from database B by using the query (Select MerchantID from Merchant_Location where LocationID= ‘particular LocationID’).
I need some help with the syntax for a query like this in SQL Server 2005. Thank you in advance!
INSERT INTO A.dbo.Merchant_Category (MerchantCategoryID, MerchantID)
SELECT MerchantLocationCategoryID, (MerchantID from Merchant_Location where LocationID = @Location) as MerchantID FROM B.dbo.Merchant_Location_Category
You can JOIN across databases in an
INSERT, just like aSELECT. Most systems will allow it in anUPDATEas well.