Reputation: 21
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.
Upvotes: 1
Views: 70
Reputation: 21
Thank you everyone that responded to my question. Sugergrady we were on the 10 yard line. The Manager and Nbr needed to be flipfloped. We got what was needed from this project at work. So Thank you everyone.
Upvotes: 0
Reputation: 1322
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
Upvotes: 1