如何将值插入临时表中的值到sql server 2008 r2中的原始表 [英] How to get values inserted into temp table to my original table in sql server 2008 r2

查看:87
本文介绍了如何将值插入临时表中的值到sql server 2008 r2中的原始表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的存储过程中创建一个临时表,其中一个字段是我正在使用scope_identity()其他字段本身就是一个标识。我想要的是临时表应该获得与范围标识的单个值对应的行(多个)。喜欢

I want to create a temp table in my stored procedure in which one field is i am getting using scope_identity() other field is itself an identity. What i want is that the temp table should get rows (which are multiple ) corresponding to the single value of scope identity. like

columnA ColumnB

111        X

111        Y

111        z



然后我希望将这些值插入到我的原始表中。有可能怎么样?



谢谢


and then i want these values to be inserted into my original table. Is it possible How?

Thank you

推荐答案

如果你使用范围标识来存储另一个表标识字段,然后你想要将它的值插入你的临时表,你应该考虑如果你的临时表还有一个标识列,范围标识的值在每次插入临时表时都会发生变化,

所以你必须存储范围标识的值在另一个变量中然后用它来插入。



作为一种解决方案,你可以将范围标识存储到另一个变量中。
If you use scope identity for storing another table identity field,and then you want to insert it's value to your temp table, you should consider that if your temp table has also an identity column, the value of scope identity is changing during each insertion to temp table,
so you must store the value of scope identity in another variable and then use it for insertion.

as a solution you can store scope identity into another variable.


这篇关于如何将值插入临时表中的值到sql server 2008 r2中的原始表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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