Actually... it should probably read....

DECLARE @Max_ID INTEGER

SELECT @Max_ID = MAX(IDField) FROM tablename

IF @Max_ID = NULL
         SELECT 1  (Not Zero!!)
ELSE
         SELECT @Max_ID + 1


N




At 13:48 17/05/00 -0700, you wrote:
>I am trying to write a SP for SQL7 that is freaking on me.  Everything 
>below works GREAT unless the database is totally empty with no records in 
>there.  Well if there are no records in the db yet, the max(IDField) isn't 
>working properly.  If there is no records in the DB yet, I need to have 
>@Max_ID set to '0'.
>
>Declare @Max_ID Integer
>Select  @Max_ID = max(IDField) + 1 From tablename
>
>
>Ideas?
>
>Todd DeFrane
>CFBoards.com
>------------------------------------------------------------------------------
>Archives: http://www.eGroups.com/list/cf-talk
>To Unsubscribe visit 
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or 
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in 
>the body.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to