select *
INTO [dbo].[aTable]
from dbo.bt btg left join dbo.btt bta on btg.specialty = bta.specialty
order by 1, 6
I am getting the following error:
Column names in each table must be unique. Column name 'Specialty' in table 'aTable' is specified more than once.
Columns for bt
table:
Location
Specialty
Provider
Column for btt
table:
Specialty
Topic
I am trying to get Location, Specialty, Provider, and (join all topics for the specialty).
The issue here is the "Select *", which will select all fields in your result set. Try specifying the specific fields that you want to insert.
For instance:
SELECT Location, btg.Specialty, Provider, Topic
INTO INTO [dbo].[aTable]
from dbo.bt btg left join dbo.btt bta on btg.specialty = bta.specialty
order by 1, 6
Alias name is all you need to mention to avoid conflict when you join two tables with same column names.
SELECT btg.Location, btg.Specialty, btg.Provider,btg.Topic
INTO INTO [dbo].[aTable]
from dbo.bt btg join dbo.btt bta on btg.specialty = bta.specialty
order by 1, 6
you can do something like this:
select btg.*, topic
INTO [dbo].[aTable]
from dbo.bt btg left join dbo.btt bta on btg.specialty = bta.specialty
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.