Convert old syntax

  • I am cleaning up a number of stored procedures and have come accross quite a few with the following operators:

    WHILE @@fetch_status != -1

    So, two questions:

    1) What is the current equivalent of this code

    2) Does anyone know of a web site that might list a definition of these older operators.

    Tried google, bing and yahoo and these characters are not recognized as searchable.

    Thanks All!!

  • != is a C style not equal operator and works just fine in SQLServer.

    declare @x int,@y int

    select @x = 0

    select @y = 1

    if(@x != @y) begin

    Select 'not equal'

    end

    Are you getting confused with the old outer join operators *= and =* ?

    EDIT :

    BOL Link http://msdn.microsoft.com/en-us/library/ms173545.aspx



    Clear Sky SQL
    My Blog[/url]

  • From Books Online (SQL 2008)

    != (Not Equal To) (Transact-SQL)

    Tests whether one expression is not equal to another expression (a comparison operator). If either or both operands are NULL, NULL is returned. Functions the same as the <> (Not Equal To) comparison operator.

    Perfectly valid, not deprecated.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Rick Osgood-429286 (6/23/2010)


    I am cleaning up a number of stored procedures and have come accross quite a few with the following operators:

    WHILE @@fetch_status != -1

    So, two questions:

    1) What is the current equivalent of this code

    2) Does anyone know of a web site that might list a definition of these older operators.

    Tried google, bing and yahoo and these characters are not recognized as searchable.

    Thanks All!!

    These are all the same:

    declare @C int = 1, @d int = 2

    if @C<>@d print 'not equal'

    if @C!=@d print 'not equal'

    if not @C=@d print 'not equal'

    Hopefully, while you are cleaning up these procedures, you're taking care of that bigger problem at the beginning of that line: "WHILE @@fetch_status"

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • WayneS (6/23/2010)


    Hopefully, while you are cleaning up these procedures, you're taking care of that bigger problem at the beginning of that line: "WHILE @@fetch_status"

    And the one that starts DECLARE CURSOR

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks for the fast replies!!!

  • It's worth noting that ! is the logical NOT operator.

    != : not equals

    !> : not greater than

    !< : not less than

    http://msdn.microsoft.com/en-us/library/ms189863%28SQL.90%29.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply