复制插入记录的每个身份 [英] Copy Each Identity Of Inserted Records

查看:28
本文介绍了复制插入记录的每个身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张桌子第一个:

I have two table first:

Table:     TBL#Sell

   SellId    ClientId    ProductId
                1           3
                3           5
                4            6

第二个:

 Table: TBL#Sell2

    SellId      ClientId       ProductId

现在我想将第一个表的每条记录复制到第二个表.第二个表 (Sell2.SellId) 中的SellId"列是 Auto Increment (Identity).

Now I want to copy every record of first table to second one. "SellId" column in second table (Sell2.SellId) is Auto Increment (Identity).

对于任何插入,TBL#Sell2.SellId 将设置为新身份,我必须将身份存储在 TBL#Sell1.SellId
清楚了吗?
解决办法是什么?,请.谢谢

for any insert the TBL#Sell2.SellId will set with new identity and i must store the identity in TBL#Sell1.SellId
Is it clear?
What is the solution? , plz. thanks

我想将 TBL#Sell2.SellId 存储在 TBL#Sell.SellId 中

推荐答案

你可以使用触发器 :

http://msdn.microsoft.com/en-us/magazine/cc164047.aspx

http://msdn.microsoft.com/en-us/library/aa258254(v=sql.80).aspx

这篇关于复制插入记录的每个身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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