need quick easy answer

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

     

  • If @ACCOUNTTIME==NULL

    @ACCOUNTTIME=0

  • Or better yet --

    If @ACCOUNTTIME is NULL

    @ACCOUNTTIME=0

  • If @ACCOUNTTIME is NULL set @ACCOUNTTIME=0

     

  • Follow the game

    set @ACCOUNTTIME= ISNULL(@ACCOUNTTIME,0)

     


    * Noel

  • and to finish this game :

    SET @ACCOUNTTIME = COALESCE(@ACCOUNTTIME,0)

  • Who said is finished?

    select @ACCOUNTTIME = case when @ACCOUNTTIME is null then 0 else @ACCOUNTTIME  end

     


    * Noel

  • 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

     

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