Hi All,
I've to transfer the data from one Line table to another Line table based on the "Doc_Status" present in the Header Table.
Example:
I've 4 records in EMP_Header but only 2 records with EMP_ID: 2 & 4 are Approved(Doc_Status), So I need to copy only the lines of 2 records with EMP_ID: 2 & 4.
Below is My code, please enhance my code.
INSERT INTO [dbo].[EMP_Test_Header]
([EMP_ID]
,[EMP_Name]
,[DOC_Status]
,[Gender]
,[Int_Flag])
SELECT emp.[EMP_ID]
,emp.[EMP_Name]
,emp.[DOC_Status]
,emp.[Gender]
,emp.[Int_Flag]
FROM [EMP_Header] emp
where emp.[DOC_STATUS] = 'Approved' and emp.[Int_Flag] = 'C'
INSERT INTO [dbo].[EMP_Test_Line]
([EMP_ID]
,[Line_No]
,[Subject]
,[Marks]
,[Int_Flag])
SELECT line.[EMP_ID]
,line.[Line_No]
,line.[Subject]
,line.[Marks]
,line.[Int_Flag]
FROM [EMP_Line] line
where line.[Int_Flag] = 'C'
Thanks in Advance,
Srinivas Maddula.