Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

!=

Options
  • 04-10-2006 11:15pm
    #1
    Registered Users Posts: 1,002 ✭✭✭


    Can someone tell me what this symbol means (!=):

    @Year != '1998'

    (when @Year is
    - EQUAL TO
    - NOT EQUAL TO
    - Other?
    1998)


Comments

  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    '!=' is NOT EQUALS TO.
    What language is this in? Can you show some more code? What variable type is @Year.
    My first thought was @Year was a perl list and it was seeing if there were 1998 elements in it, but the quotes make me think otherwise.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    '!' means 'not'.
    = means 'equal'

    != means 'not equal'

    Similarly !< means 'not les than'. etc

    EDIT: It looks like an SQL query to me.


  • Registered Users Posts: 1,002 ✭✭✭MargeS


    Mutant_Fruit is most correct - SQL

    I was going through some of the stored procs in the Northwind database to see how other people write them. The SalesByCategory SP starts off with:

    @CategoryName nvarchar(15),
    @OrdYear nvarchar(4) = '1998'

    AS
    IF @OrdYear != '1996' AND @OrdYear != '1997' AND @OrdYear != '1998'
    BEGIN
    SELECT @OrdYear = '1998'
    END

    I can't figure why they go OrdYear IS NOT EQUAL to 1998 and then SELECT ordyear as 1998 two lines later


  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    MargeS wrote:
    I can't figure why they go OrdYear IS NOT EQUAL to 1998 and then SELECT ordyear as 1998 two lines later
    Can one put comments in stored procedures? If you can, when you figure out the reason for the code, add comments, for yourself and others.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Yeah, comments in sql code are easy. For Sql Server it's '--' for a single line or good old '/*' and '*/' for multiline. I'd imagine its the same for most.
    I can't figure why they go OrdYear IS NOT EQUAL to 1998 and then SELECT ordyear as 1998 two lines later
    Easy enough, they want @OrdYear in that range of years, if its not they set it to 1998.


  • Advertisement
  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    MargeS wrote:
    I can't figure why they go OrdYear IS NOT EQUAL to 1998 and then SELECT ordyear as 1998 two lines later

    You seem to be ignoring the use of the word IF in the first case.

    if the year is not 1996, is not 1997 and is not 1998
    then set the year equal to 1998

    What doesn't make sense about that?
    Evil Phil wrote:
    Yeah, comments in sql code are easy. For Sql Server it's '--' for a single line or good old '/*' and '*/' for multiline. I'd imagine its the same for most.

    It is indeed the same for most, because these are the two standards-compliant definitions for comments in SQL.

    -- is ANSI/ISO standard, and /* */ is SQL-99, if memory serves.


Advertisement