简体   繁体   English

将类似的列从一个表复制到另一个表并将文本从文本框中复制

[英]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. 我在SQL中有两个表table1和table2,它们为A,B,C,D,E列共享相同的名称。 But lets same table1 also has F,G,H,I,J,K,L and table2 has one called 'statement'. 但是让同一个表1也具有F,G,H,I,J,K,L,而表2具有一个称为“语句”的语句。 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. 我想做的是按下按钮,将table1复制到table2类似的列,并从文本框中获取文本,然后将其保存到table2语句列。

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? 但是我需要在同一查询中从文本框中获取文本,并将其保存到table2中的“ statement”列中……有什么想法吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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