Background:I need to create some new records using data from old serial numbers. After this process has completed, I will mark the old serial numbers as invalid (we keep a paper trail; we do not delete the records).I am trying to use this basic INSERT statement, but it does not seem to like me using a SELECT statement in the VALUES section:DECLARE @OldNumber char(20), @NewNumber char(20)SET @OldNumber='CP21253 1015 09' -- 'CP21253 1018 09''CP21253 1014 09''CP21253 1009 09''CP21253 1008 09'SET @NewNumber='CP21253 1022 09' -- 'CP21253 1021 09''CP21253 1020 09''CP21253 1019 09''CP21253 1001 09',INSERT INTO ACP_Parts (OP_ID, Serial_Number, Date_Time, System_ID, Test_Result, WorkOrder_Number, WorkOrder_Qty, WorkOrder_Seq, Line_Number, CoilType, TubeWall, BrazeJoint, Supervisor)VALUES ( SELECT OP_ID, @NewNumber as 'Serial_Number', Date_Time, System_ID, Test_Result, WorkOrder_Number, WorkOrder_Qty, WorkOrder_Seq, Line_Number, CoilType, TubeWall, BrazeJoint, Supervisor FROM ACP_Parts WHERE (Serial_Number=@OldNumber))
The error messages from Query Analyzer are:quote:
Server: Msg 156, Level 15, State 1, Line 8Incorrect syntax near the keyword 'SELECT'.Server: Msg 170, Level 15, State 1, Line 10Line 10: Incorrect syntax near ')'.