Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

MS SQL Insert Using Data from 2 Different Tables

$
0
0

I am trying to insert some data into a table using some text values in addition to some data being pulled from a couple other tables.

Inserting into PhoneList and pulling data from PhoneListDepartments and PhoneListOffice

PhoneListDepartments has fields: PhoneListDepartmentID (links to PhoneList record) and PhoneListDepartment (contains department name). PhoneListOffice table has fields: PhoneListOfficeID (link to PhoneList record) and PhoneListOffice (contains office name).

My query is:

Text
INSERT INTO Phonelist (Active, Visible, FirstName, LastName, Business, PhoneListOfficeID, PhoneListDepartmentID)SELECT 'True' AS Expr4, 'True' AS Expr5, 'TEST' AS Expr1, 'USER' AS Expr2, '310-555-1234' AS Expr3, PLO.PhoneListOfficeID, PLD.PhoneListDepartmentIDFROM PhoneListOffice AS PLO INNER JOIN Phonelist AS PL ON PL.PhoneListOfficeID =...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>