SQL select into query

Can someone help with what is wrong with my syntax below on my SQL statement?  I get  Error: Column names in each table must be unique. Column name 'CUSTEDP' in table 'IBGTEMP_ACCTCOMM_BACKUP' is specified more than once. (State:S0021, Native Code: A91) I'm trying to backup select records from ACCTCOMMENTS table into a backup table called IBGTEMP_ACCTCOMM_BACKUP.

SELECT * INTO IBGTEMP_ACCTCOMM_BACKUP
FROM ACCTCOMMENTS ACMT
INNER JOIN STANDINGHEADER STHD
ON ACMT.CUSTEDP = STHD.CUSTEDP
WHERE STHD.CUSTEDP=ACMT.CUSTEDP AND ACMT.TYPE='SO'
LVL 1
ibgadminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leo TorresSQL DeveloperCommented:
Looks like in the columns selected you have columns that have the same name. I would Explicitly write out all the columns needed to be put on to the new into Table.

You can have the new table have columns with the same names I would name them something else when you explicitly write them
0
Leo TorresSQL DeveloperCommented:
Remember your "*" is bring columns from all tables in the Join
This might work try it
SELECT ACMT.* INTO IBGTEMP_ACCTCOMM_BACKUP
 FROM ACCTCOMMENTS ACMT
 INNER JOIN STANDINGHEADER STHD
 ON ACMT.CUSTEDP = STHD.CUSTEDP
 WHERE STHD.CUSTEDP=ACMT.CUSTEDP AND ACMT.TYPE='SO' 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ibgadminAuthor Commented:
That did it Leo, thanks so much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.