简体   繁体   中英

copy like columns from one table to another and text from textbox

I have two tables in SQL, table1 and table2, and they share the same names for columns A,B,C,D,E. But lets same table1 also has F,G,H,I,J,K,L and table2 has one called 'statement'. What I would like to do is on a button press, copy table1 to table2 similar columns AND take the text from a textbox and save it to table2 statement column.

I have this that I think would work:

    INSERT INTO table2 (A,B,C,D,E)
    select (A,B,C,D,E)
    from table1

but I need to get the text from the text box in the same query and save that to column 'statement' in table2 as well...any ideas?

My recommendation is to create a stored procedure that accepts the text from your textbox as a parameter and performs the insert as such:

INSERT INTO table2 (A,B,C,D,E,Statement)
    select (A,B,C,D,E, @Statement)
    from table1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM