> 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?

if you have no rows in that table then max(IDfield) == NULL,
in sql server NULL + 1 == NULL. test if its NULL & then set
equal to 0.

------------------------------------------------------------------------------
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