Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Posts
    15

    Unanswered: CASE statement question

    hi,

    Suppose I want to do the following:

    DECLARE @num
    SET @num = -1 /* initial value */

    SELECT col1, col2,
    CASE @num
    WHEN -1 THEN ( [assign a value to @num], [return that value] )
    ELSE @num
    END AS 'num'
    FROM T1

    In English, I only want the @num variable to be calculated once but appear in every column of the SELECT result, since table T1 has many rows.

    Greatly appreciate any help... thanks in advance!!

  2. #2
    Join Date
    Jul 2001
    Location
    Germany
    Posts
    189

    which database

    Hello,

    it looks like SQL Server ???? Is it true ?

    Best regards
    Manfred Peter
    (Alligator Company GmbH)
    http://www.alligatorsql.com

  3. #3
    Join Date
    Feb 2003
    Posts
    15
    Yes... it is SQL Server...

Posting Permissions

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