Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否SET IDENTITY_INSERT [Table] ON持续超出 SQL 脚本的范围?我想知道是否需要将其显式设置为“OFF”,或者 SQL Server 是否知道它应该只对当前脚本使用该设置。
SET IDENTITY_INSERT [Table] ON
谢谢!
是的,它确实存在于当前批次之外。
但是,它不会在当前会话之后持续存在,因此如果您在运行后立即断开连接,则无需更改它。
顺便说一句,每个会话一次只能为一个表打开,正如 Aaron 在下面的评论中指出的那样,如果您尝试为每个会话设置多个表,则会引发错误。