September 15, 2005 at 11:09 am
I don't have a book handy and just need a quick answer to a question
about stored procedure syntax, it keeps reporting bad syntax. Here is all I want to do:
If @ACCOUNTTIME==NULL then @ACCOUNTTIME=0
Someone please help, I have SQL server 2000.
Thanks.
September 15, 2005 at 11:11 am
If @ACCOUNTTIME==NULL
@ACCOUNTTIME=0
September 15, 2005 at 11:12 am
Or better yet --
If @ACCOUNTTIME is NULL
@ACCOUNTTIME=0
September 15, 2005 at 11:14 am
If @ACCOUNTTIME is NULL set @ACCOUNTTIME=0
September 15, 2005 at 11:19 am
Follow the game
set @ACCOUNTTIME= ISNULL(@ACCOUNTTIME,0)
* Noel
September 15, 2005 at 11:23 am
and to finish this game :
SET @ACCOUNTTIME = COALESCE(@ACCOUNTTIME,0)
September 15, 2005 at 11:28 am
Who said is finished?
select @ACCOUNTTIME = case when @ACCOUNTTIME is null then 0 else @ACCOUNTTIME end
* Noel
September 15, 2005 at 11:57 am
Thanks for all the replies! This is what worked:
IF @CALLLOGTIME IS NULL SET @CALLLOGTIME=0
The following did NOT work - gave a syntax error (I don't know why either, they look good, maybe its my SQL version or something)
IF @CALLLOGTIME==NULL @CALLLOGTIME=0
IF @CALLLOGTIME==NULL SET @CALLLOGTIME=0
September 15, 2005 at 12:05 pm
== is not gonna work with sql
if @var = null is also gonna fail most of the time.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply