相当于SQL Anywhere GET_IDENTITY? [英] Equivalent to SQL Anywhere GET_IDENTITY?

查看:81
本文介绍了相当于SQL Anywhere GET_IDENTITY?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mssql中是否有与SQL Anywhere的GET_IDENTITY相同的

保留表的下一个autoinc值?是的我知道

@@ Identity和SCOPE_IDENTITY。我需要获得下一个autoinc值

_before_由于现有应用程序

的工作方式,我插入记录。


我看过DBCC CHECKIDENT,但这对我来说似乎很吵。


TIA,

Jim

Is there an equivalent in mssql to SQL Anywhere''s GET_IDENTITY which
reserves the next autoinc value for a table? Yes I know about
@@Identity and SCOPE_IDENTITY. I need to get the next autoinc value
_before_ I insert the record due to the way the existing application
works.

I''ve seen DBCC CHECKIDENT mentioned but that seems kludgy to me.

TIA,
Jim

推荐答案

Jim C写道:
Jim C wrote:

mssql中是否有等价于SQL Anywhere的GET_IDENTITY

保留表的下一个autoinc值?是的我知道

@@ Identity和SCOPE_IDENTITY。我需要获得下一个autoinc值

_before_由于现有应用程序

的工作方式,我插入记录。


我已经看过DBCC CHECKIDENT了,但这对我来说似乎很蹩脚。


TIA,

Jim
Is there an equivalent in mssql to SQL Anywhere''s GET_IDENTITY which
reserves the next autoinc value for a table? Yes I know about
@@Identity and SCOPE_IDENTITY. I need to get the next autoinc value
_before_ I insert the record due to the way the existing application
works.

I''ve seen DBCC CHECKIDENT mentioned but that seems kludgy to me.

TIA,
Jim



您无法可靠地确定下一个IDENTITY值,除非在

a单用户系统中。不过还有其他方法:

http://www.sqlmag.com/Article/Articl...ver_48165.html

-

David Portas,SQL Server MVP


只要有可能,请发布足够的代码来重现您的问题。

包含CREATE TABLE和INSERT语句通常会有所帮助。

State你正在使用什么版本的SQL Server并指定内容

的任何错误消息。


SQL Server联机丛书:
http://msdn2.microsoft.com/library/m ...... S,SQL.90).aspx

-

You cannot reliably determine the next IDENTITY value, except maybe in
a single user system. There are other ways however:

http://www.sqlmag.com/Article/Articl...ver_48165.html

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--


Jim C(ji ** ********@gmail.com)写道:
Jim C (ji**********@gmail.com) writes:

mssql中是否有等价于SQL Anywhere的GET_IDENTITY

保留ne表的xt autoinc值?是的我知道

@@ Identity和SCOPE_IDENTITY。我需要获得下一个autoinc值

_before_由于现有应用程序

的工作方式,我插入记录。
Is there an equivalent in mssql to SQL Anywhere''s GET_IDENTITY which
reserves the next autoinc value for a table? Yes I know about
@@Identity and SCOPE_IDENTITY. I need to get the next autoinc value
_before_ I insert the record due to the way the existing application
works.



函数ident_current()是您要查找的函数,但它返回的值

对所有进程都是全局的,所以如果你调用ident_current(),

插入一行,然后看看scope_identity()你可能会看到一个不同的

值,如果另一个进程在同一时间。

-

Erland Sommarskog,SQL Server MVP, es **** @ sommarskog .se


SQL Server 2005联机丛书
http://www.microsoft.com/technet/pro...ads/books.mspx

用于SQL Server 2000的联机书籍
http ://www.microsoft.com/sql/prodinf...ons/books.mspx

The function ident_current() is the one you are looking for, but the value
it returns is global to all processes, so if you call ident_current(),
insert a row and then look at scope_identity() you may see a different
value, if another process was at it at the same time.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


我没有订阅该网站,可以没见第一页。


David Portas写道:
I don''t subscribe to that site and can''t see past the first page.

David Portas wrote:

您无法可靠地确定下一个IDENTITY值,除非在

a单用户系统。不过还有其他方法:

http://www.sqlmag.com/Article/Articl...ver_48165.html


这篇关于相当于SQL Anywhere GET_IDENTITY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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