Home Forums SQL Server 2005 T-SQL (SS2K5) EXISTS Subqueries: SELECT 1 vs. SELECT * (Database Weekly 11.02.2008) RE: EXISTS Subqueries: SELECT 1 vs. SELECT * (Database Weekly 11.02.2008)

  • All Conor was talking about was the difference between

    IF EXISTS (SELECT 1 FROM SomeTable WHERE SomeCondition)

    and

    IF EXISTS (SELECT * FROM SomeTable WHERE SomeCondition)

    True. The use of *, as noted, is not good for the existance test subquery. Often, you see SELECT 1 as noted, or SELECT 'x', or something equiv. I'm just stating that you can use NULL as in:

    IF EXISTS (SELECT NULL FROM SomeTable WHERE SomeCondition)


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]