June 23, 2010 at 7:28 am
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!!
June 23, 2010 at 7:36 am
!= 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
June 23, 2010 at 7:37 am
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
June 23, 2010 at 7:49 am
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
June 23, 2010 at 7:58 am
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
June 23, 2010 at 8:02 am
Thanks for the fast replies!!!
June 23, 2010 at 8:08 am
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
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply