简体   繁体   English

从一个表存储到另一表中的记录中获取附加数据

[英]Pull record from one table store in another table with additional data

I am pulling records from one table into another like this 我正在将记录从一张桌子拉到另一张这样

strsql = strsql & " INSERT INTO Activity (noteKey, originalNoteEmp, originalNoteDate, data)" &
    "SELECT NoteKey, UserName, NoteDate, Notes " & 
    "FROM dbo.Note " & 
    "WHERE NoteKey = " & lngNoteKey

My question is, how can I add additional data to be inserted into the table if the data isn't inside of the orginal table it is data which is derived from the application it self. 我的问题是,如果数据不是原始表中的数据(是从其自身的应用程序派生的数据),则如何添加要插入表中的其他数据。 Ie additional variables. 即其他变量。

Is there a way to add it to this command? 有没有办法将其添加到此命令?

Lets say you have 2 fields - id and name . 假设您有2个字段-idname In your project you need to insert them into table but id comes from another table and name comes from application 在您的项目中,您需要将它们插入表中,但id来自另一个表, 名称来自应用程序

sql = "INSERT INTO tbl1 (id, name) select (id, '" & txtbox.Text & "') FROM tbl2..."

I think, this will give you an idea and you can work from here. 我认为,这会给您一个想法,您可以从这里开始工作。

Of course, if you inserting multiple records, you will have to go row-by-row. 当然,如果插入多个记录,则必须逐行进行。

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

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