DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
MSSQL 2005 - Add ID Value To ID Column When INSERTING
// @TableName is obviously the TABLE name u use
// @ColumnName is obviously the COLUMN name u use
---Get next ID number DECLARE @ID int IF (SELECT count(*) FROM @TableName ) > 0 BEGIN SELECT @ID = max(ColumnName ) from @TableName SET @ID = @ID + 1 END ELSE BEGIN SET @ID = 1 END






Comments
Mark Macumber replied on Thu, 2007/08/16 - 10:20pm