Showing posts with label MS SQL. Show all posts
Showing posts with label MS SQL. Show all posts

SQL Server: Difference between <> and != operator

Two Different Not equal to operators - Difference
Once I was using <> operator in a query.
select * from Mytable where col1 is not null and col1 <> ''
Where as one of my colleagues used != operator.
select * from Mytable where col1 is not null and col1 != ''
Both the queries resulted the same. I just googled to know the answer and I got this

http://msdn.microsoft.com/en-us/library/ms188074.aspx

There is no difference between both the operators technically or performance wise.
!= operator is not an ANSI standard. So better to use <> operator.

Search a function

To populate all User-Defined functions in the current database we can use the query
SELECT *
FROM sys.objects
WHERE type IN ('FN', 'IF', 'TF')
To search specific User-Defined function by name we can use
SELECT *
FROM sys.objects
WHERE type IN ('FN', 'IF', 'TF') and name LIKE '%zero%'