如何设置范围标识 [英] How to set Scope identity

查看:125
本文介绍了如何设置范围标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的DO表中,SlNo列现在具有标识,我必须为Scope设置相同的标识.在我的代码下方

Hi

In my DO table SlNo column have identity now i i have to set Scope identity for the same.below my code

string sqlcommand = "SELECT DoNo,SlNo from DO where DoNo = DoNo, SET @SlNo=CAST(SCOPE_IDENTITY() AS int";


您能帮忙设置吗?

目前,我在int附近收到一条错误消息msg.

问候
Lancy


Could you please help how to set?

At present i am getting a error msg error near int.

Regards
Lancy

推荐答案

尝试阅读本 http://msdn.microsoft.com/en-us/library/ms190315.aspx [
Try reading this http://msdn.microsoft.com/en-us/library/ms190315.aspx[^] to understand what SCOPE_IDENTITY is.


尝试一下:

Try this :

string sqlcommand = "SELECT DoNo,SlNo from DO where DoNo = DoNo; SET @SlNo=CAST(SCOPE_IDENTITY() AS int)";



用;"代替,"在两个命令之间,并在末尾添加一个括号.



Substituted "," by ";" between two commands and added a parentheses at the end.


这篇关于如何设置范围标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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