表中标识列的显式值

编程入门 行业动态 更新时间:2024-10-20 16:44:50
本文介绍了表中标识列的显式值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

hi 如何解决此错误 我的代码:

hi How Solve This Error my code :

SET IDENTITY_INSERT UserProfile ON GO INSERT INTO UserProfile SELECT up.UserId-2002, up.UserName, up.Name, up.Family, up.P_T, up.P_N, up.Reshteh, up.CodeOzviat, up.CodeParvaneh FROM UserProfile up WHERE (UserId =2336) GO SET IDENTITY_INSERT UserProfile OFF

和错误:

and error :

Msg 8101, Level 16, State 1, Line 1 An explicit value for the identity column in table 'UserProfile' can only be specified when a column list is used and IDENTITY_INSERT is ON.

推荐答案

您忘记在INSERT命令中指定列列表,如: You forgot to specify the columns list in your INSERT command like: SET IDENTITY_INSERT UserProfile ON GO INSERT INTO UserProfile (UserId, UserName, Name, Family, P_T, P_N, Reshteh, CodeOzviat, CodeParvaneh) SELECT up.UserId-2002, up.UserName, up.Name, up.Family, up.P_T, up.P_N, up.Reshteh, up.CodeOzviat, up.CodeParvaneh FROM UserProfile up WHERE (UserId =2336) GO SET IDENTITY_INSERT UserProfile OFF

更多推荐

表中标识列的显式值

本文发布于:2023-11-16 01:38:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1599823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标识   显式值

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!