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)

  • Better syntax:

    Use NULL vs. a literal such as 1 or 'x' as in:

    SELECT NULL FROM ...

    Sample code using EXISTS that checks for the proper installation of the full-text filters for various document types:

    -- Ensure that the IFilter interfaces (filters) are enabled for ALL of the document types supported by the product.

    -- Abort if they are not.

    IF NOT EXISTS

    (

    SELECT NULL

    WHERE EXISTS (SELECT NULL FROM sys.fulltext_document_types WHERE document_type = N'.doc')

    AND EXISTS (SELECT NULL FROM sys.fulltext_document_types WHERE document_type = N'.ppt')

    AND EXISTS (SELECT NULL FROM sys.fulltext_document_types WHERE document_type = N'.pdf')

    )

    BEGIN;

    RAISERROR('The required IFilters are not enabled or installed - aborting', 16, 1);

    END;

    GO


    [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]