DECLARE @minidentval TYPE DECLARE @nextidentval TYPE DECLARE @count INT SELECT @count = COUNT(*) FROM [Table_name] SELECT @minidentval = MIN($IDENTITY) FROM [Table_name] IF @minidentval = IDENT_SEED('[Table_name]') SELECT @nextidentval = MIN($IDENTITY) + IDENT_INCR('[Table_name]') FROM [Table_name] t1 WHERE $IDENTITY BETWEEN IDENT_SEED('[Table_name]') AND @count AND NOT EXISTS (SELECT * FROM [Table_name] t2 WHERE t2.$IDENTITY = t1.$IDENTITY + IDENT_INCR('[Table_name]')); ELSE SELECT @nextidentval = IDENT_SEED('[Table_name]')
댓글 없음:
댓글 쓰기