从一个表中选择一个值,然后插入到另一个表中 [英] Select a value from one table and insert into another table

查看:88
本文介绍了从一个表中选择一个值,然后插入到另一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是dotnet的新手,并且陷入了处理两个sql表的任务中.让我清楚地解释

我有两个表Events,user-events.我有四个asp按钮.每个按钮都分配给Events表中的每个id.单击​​按钮后,我需要将该id插入到user-events表中.

我尝试使用select语句从第一个表中检索ID,然后尝试使用insert插入第二个表中...但是它不起作用..有人可以帮我解决这个问题吗?

Hi,

I am new to dotnet and stuck in a task which deals with two sql tables. Let me explain clearly

I have two tables Events,user-events.I have four asp buttons.Each button is asssigned to each id in Events table .On button click i need to insert that id in user-events table.

I tried using select statement for retrieving the id from first table and later using insert for inserting into second table ...But it did not work.. can anyone help me sorting out this issue

推荐答案

试试这个

try this

insert into Database1.dbo.Table1
select (AllCOl except identity Col)  from Database2.dbo.Table2


这篇关于从一个表中选择一个值,然后插入到另一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆