Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 can someone correct my insert with copy syntax?

Author  Topic 

sharc
Starting Member

8 Posts

Posted - 2010-10-11 : 10:34:45
noob question .. .
I've got a table with 3 columns. .. employeeID, company, facility.
I need to add a new employee, but copy the company and facility values of a current employee. ..

so my insert values would be (select company, facility from table1 where employeeID = '12345')
But my new employeeID would be '54321'

How would I do this :( ?

Would it be:

Insert into table1 (employeeID, company, facility)
values ('54321', (select company, facility from table1 where employeeID = '12345'))

? Help. . . I'm chicken to try the insert like that lest I mess something up!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-11 : 10:37:53
Insert into table1 (employeeID, company, facility)
select '54321', company, facility from table1 where employeeID = '12345'



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

sharc
Starting Member

8 Posts

Posted - 2010-10-11 : 11:03:30
thanks a lot webfred!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-11 : 11:18:02
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -