SQLServer's dependency on unique keys and cluster indexes mean that identity counters are very common. Again as with older versions of SQL Server these can be turned off enabling you manually set identity (if you need to)
SET IDENTITY_INSERT (Transact-SQL)
Allows explicit values to be inserted into the identity column of a table.
Transact-SQL Syntax Conventions
Syntax
SET IDENTITY_INSERT [ database_name . [ schema_name ] . ] table { ON | OFF }
Arguments
database_name
Is the name of the database in which the specified table resides.
schema_name
Is the name of the schema to which the table belongs.
table
Is the name of a table with an identity column.
Remarks
At any time, only one table in a session can have the IDENTITY_INSERT property set to ON. If a table already has this property set to ON, and a SET IDENTITY_INSERT ON statement is issued for another table, SQL Server returns an error message that states SET IDENTITY_INSERT is already ON and reports the table it is set ON for.
If the value inserted is larger than the current identity value for the table, SQL Server automatically uses the new inserted value as the current identity value.
The setting of SET IDENTITY_INSERT is set at execute or run time and not at parse time.
Permissions
User must own the object, or be a member of the sysadmin fixed server role, or the db_owner and db_ddladmin fixed database roles.
http://msdn.microsoft.com/en-us/library/ms188059.aspx
No comments:
Post a Comment