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)

  • Hm, should have checked this link first...

    Still I am not yet convinced, or at least a little confused:

    Given a table "a" with columns "cola" and "colrestricted".

    User "Test" only has access to column "cola", but not to "colrestricted".

    Then I execute the following queries:

    SELECT * FROM sys.objects WHERE EXISTS(SELECT cola FROM a)

    SELECT * FROM sys.objects WHERE EXISTS(SELECT 1 FROM a)

    SELECT * FROM sys.objects WHERE EXISTS(SELECT * FROM a)

    Now I get an error from both the 2nd and the 3rd query! (Permission denied on colrestricted)

    Why is query 2 (SELECT 1... ) giving me an error?

    Thought Id ask you first instead of addressing this to Conor directly. There is probably a simple explanation...

    Thanks!

    Best Regards,

    Chris Büttner