It might seem strange, but T-SQL has an IDENTITY() property and an IDENTITY() function, each of which serve a (similar, but) different purpose.
- The
IDENTITY()property creates an identity column in a table. An identity column contains an automatically incrementing identification number. This property is used with theCREATE TABLEandALTER TABLEstatements. - The
IDENTITY()function however, is used only in aSELECTstatement with anINTOtable clause to insert an identity column into a new table.
There’s also the SQL-DMO Identity property that exposes the row identity property of a column, but I won’t cover that here. Microsoft advises that this property will be removed in a future version of SQL Server, and that you should avoid using it in new development work.