0

TSQL How do I create a new table from two existing table? Want a new table Called EmployeeInfo that has the information from both EmploeeDemographics and EmployeeSalary

SELECT * 
FROM [dbo].[EmploeeDemographics]
right outer join [dbo].[EmployeeSalary] 
    on EmploeeDemographics.EmployeeID=EmployeeSalary.EmployeeID
Charlieface
  • 52,284
  • 6
  • 19
  • 43
  • 3
    `SELECT * INTO [newTableName] FROM ...` But you will need to mention the columns explicitly, because `EmployeeID` exists in both, and column names need to be unique – HoneyBadger Mar 22 '22 at 10:24
  • But why? Generally speaking, the goal of a relational database is to **remove** duplication. – SMor Mar 22 '22 at 10:58
  • @SMor This is just a basic mock example. I need to create a new temp table from bunch of queries which I can then connect into using spark for example https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/data-sources/apache-spark-sql-connector. This then allows me to get the data i want for ml in one table as I can read it as a dataframe. – Muhammad Ashraf Mar 22 '22 at 11:24

0 Answers0