是否可以在同一过程中使用两个 SCOPE_IDENTITY 调用?
我希望我的存储过程的工作方式是这样的,用户将所有客户数据、姓名、电话和所有地址信息传递到该过程中,然后我想执行插入到地址表中,生成生成的 id从该插入中,在客户表的另一个插入中使用该 ID,然后将客户 ID 返回给应用程序端的用户。这在同一个存储过程中是否可能,或者是否非常违反标准,您有什么建议?
The way I want my stored procedure to work is this, the user passes all of the customer data, name, phone, and all of address info into the procedure, then I want to perform an insert into the address table, get the id generated from that insert, use that id in another insert for the customer table then return the customer id to the user on the app side. Is this possible within the same stored procedure or is it highly against standards and what do you suggest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是可能的,但我个人会将其与地址和客户表的单独过程分开。这将为您提供更大的灵活性和更多将来代码重用的机会。
Yes it's possible, but personally I'd compartmentalize this with separate procedures for the Address and Customer tables. This should give you greater flexibility and more opportunities for code reuse in the future.