Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Posts
    47

    Question Unanswered: Checking a value in a variable in stored proc.

    Hi I m using Dynamic SQL and assigning the result returned by the select query in a variable...For further mathematical calculations I want check if the value returned by the Query is 0 or null or some other value...how can I check it?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    IF @variable IS NULL or @variable = 0
      BEGIN
        PRINT 'variable is bad'
      END
    ELSE
      BEGIN
        PRINT 'variable is gooooood'
      END
    George
    Home | Blog

  3. #3
    Join Date
    Dec 2008
    Posts
    135
    Code:
    select columnsname, case when @variable IS NULL or @variable = 0
    then 'novalue' else 'value exists' end as status
    from tablename

  4. #4
    Join Date
    Mar 2009
    Posts
    47
    Thnks it worked both thye solutions are working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •