• Question of the day: what datatype is the Estimated Number of Rows (or Estimated Subtree Cost) displayed in the property sheet of the SELECT operator in the estimated plan of this batch?

    IF EXISTS (SELECT 1 FROM (VALUES(CAST(1 AS BIT))) d (n))

    WITH a AS (SELECT n = 1 FROM sys.columns a,sys.columns b,sys.columns c),

    b AS (SELECT n = 1 FROM a a, a b, a c),

    c AS (SELECT n = 1 FROM b a, b b, b c),

    d AS (SELECT n = 1 FROM c a, c b, c c)

    SELECT * FROM d

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden