If you're putting this in a sproc, you can wrap your select with conditional
logic. Such as:
Declare @Max_ID Integer
If NOT isNull(@Max_ID) then
select @Max_ID = max(IDField) + 1 from tablename
Else
@Max_ID = 0
End If
I'm not sure if my syntax is correct (it's been a while) but you should get
the jist of what i'm saying. Good luck.
-----Original Message-----
From: cftalk [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 17, 2000 1:48 PM
To: [EMAIL PROTECTED]
Subject: Problem Declaring Stored Procedure with Max(blah)
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.