Hope you all can help me out here. I imported an excel file successfully into Microsoft SQL Server 2016. I have another table so a grand total of two tables. The field in common with both tables is a column named ProjectManager. One table has only two columns ProjectManager, and projectNbr. I want to join that table with another table. ProjectManager is in both tables. I also want to update the table that I am joining to include the column projectNbr. One table is named dbo.Importthis, the other is named dbo.WTS_EXT_Project. I want to be able to join both together and update the one to include projectNbr column. Is there a command statement to accomplish this at one statement? Alieases are ok to use. If you all need more information or anything else let me know. Would appreciate any assistance.
Here is how you add a column to a table. I'm assuming projectNbr is an integer:
ALTER TABLE dbo.WTS_EXT_Project ADD COLUMN projectNbr INT
Then to fill your new column from the Importthis table, it would look something like this:
UPDATE wep SET projectNbr = it.projectNbr FROM dbo.WTS_EXT_Project wep INNER JOIN dbo.Importthis it ON wep.ProjectManager = it.ProjectManager