Identity是标识值,在SQL Server中,有ID列,ID属性,ID值,ID列的值等术语。
Identity属性是指在创建Table时,为列指定的Identity属性,其语法是:column_name type IDENTITY [ (seed , increment) ],Identity属性有两个参数:seed和increment,seed是ID值的初始值,increment是ID值的增量。在Table中创建的Column,如果使用Identity属性标识,那么该列是ID列。默认情况下,不能显式向ID列插入数值。ID列是由系统自动赋值的,在赋值时,系统根据该表的ID值,自动插入递增的,唯一的数值,同时ID值根据Increment自动递增。ID值有自动递增的特性,当语句执行失败或事务回滚时,ID值不会回滚,这会导致ID列的值不连续。
如果想要显式向ID列插入特定的数值,那么,必须启用 Identity_Insert选项,该选项自动将ID值更新为ID列的最大值。
set identity_insert schema_name.table_name on
在transactional replication中,如果订阅端的ID列设置属性:not for replication,那么,当replication agent执行插入操作,该列的ID值不会增加,因此,ID列的最大值和ID值,不总是保持相同。
If this property is specified for the IDENTITY property, values are not incremented in identity columns when replication agents perform inserts.
一,Identity函数
1,只能用于select-into子句中,新建一个含有Identity 列的数据表
IDENTITY (data_type网友评论

