Results 1 to 3 of 3

Thread: if statement

  1. #1
    Join Date
    Jun 2006
    Posts
    2

    Unanswered: if statement

    hi
    i want if the cindition realization then i dont want to do anything

    declare @x varchar(50)
    set @x='zaid'
    if @x='zaid'
    --- do nothing
    else
    RAISERROR(Hi',18,1)

    and this is the error messege

    Msg 156, Level 15, State 1, Line 5
    Incorrect syntax near the keyword 'else'.

  2. #2
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    declare @x varchar(50)
    set @x='zaid'
    if not @x='zaid'
    RAISERROR('Hi',18,1)
    thats so simple man,I bet you were lazy this time.....
    Last edited by rudra; 06-02-06 at 16:45.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  3. #3
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    if @x = 'zaid' set @x = @x
    else
    raiserror...
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

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