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 2008 Forums
 Transact-SQL (2008)
 Insert while doing a select

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2012-05-01 : 14:29:15
I need to a select that pulls back all fields with a specific ID from table A and do an insert into the same table with specific fields from that select.


SELECT Ofa_Batch_Dtls_Pk, Batch_Loc_Fk, Batch_No, Inserted_Dt, Updated_Dt
FROM OFA.tblOFA_BATCH_DTLS
WHERE (Ofa_Batch_Dtls_Pk = 122315)

Dave
Helixpoint Web Development
http://www.helixpoint.com

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-01 : 14:32:41
[code]
insert into OFA.tblOFA_BATCH_DTLS
SELECT Ofa_Batch_Dtls_Pk, <someothervalue>,<someothervalue>,...
FROM OFA.tblOFA_BATCH_DTLS
WHERE (Ofa_Batch_Dtls_Pk = 122315)
[/code]


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -