sql - How to insert values into one table from another table -
i have 2 tables i.e., table1
, table2
same structure , want insert values of table1 table2. these table contains 2 image type column. have tried query couldn't succeed.
declare @imagepan varbinary(max) declare @imagecheque varbinary(max) set @imagepan=(select panid table1 emp_code='e001') set @imagecheque=(select cancel_checqe table1 emp_code='e001') insert table2 (transno, emp_code, panno, panid, panext, entdt_pan, banknm, cancel_checqe, chqext, entdt_bnk, acc_no, ifsc, cheque_nm, status_pan1, status_pan, status_bnk1, status_bnk, userid, entdt, panmodify_by, panmodify_on, bnkmodify_by, bnkmodify_on) values(select transno, emp_code, panno, @imagepan, panext, entdt_pan, banknm, @imagecheque, chqext, entdt_bnk, acc_no, ifsc, cheque_nm, status_pan1, status_pan, status_bnk1, status_bnk, userid, entdt, panmodify_by, panmodify_on, bnkmodify_by, bnkmodify_on table1 emp_code='e001')
how can achieve this?
remove 'values' keyword
insert table2 (transno, emp_code, panno, panid, panext, entdt_pan, banknm, cancel_checqe, chqext, entdt_bnk, acc_no, ifsc, cheque_nm, status_pan1, status_pan, status_bnk1, status_bnk, userid, entdt, panmodify_by, panmodify_on, bnkmodify_by, bnkmodify_on) select transno, emp_code, panno, @imagepan, panext, entdt_pan, banknm, @imagecheque, chqext, entdt_bnk, acc_no, ifsc, cheque_nm, status_pan1, status_pan, status_bnk1, status_bnk, userid, entdt, panmodify_by, panmodify_on, bnkmodify_by, bnkmodify_on table1 emp_code = 'e001';
Comments
Post a Comment