How to Create an Identity Column with SQL “Into” Statement

Use the syntax below to create an identity column with an “Into” statement.

SELECT IDENTITY(INT, 1, 1) AS MyIdentityColumn
	,Name
INTO #temp
FROM dbo.SysObjects
Where	XType = 'U'
Order by Name
Advertisements