SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Insert while doing a select
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

helixpoint
Constraint Violating Yak Guru

250 Posts

Posted - 05/01/2012 :  14:29:15  Show Profile  Reply with Quote
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

India
47069 Posts

Posted - 05/01/2012 :  14:32:41  Show Profile  Reply with Quote

insert into OFA.tblOFA_BATCH_DTLS
SELECT Ofa_Batch_Dtls_Pk, <someothervalue>,<someothervalue>,...
FROM OFA.tblOFA_BATCH_DTLS
WHERE (Ofa_Batch_Dtls_Pk = 122315)



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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000