• dwain.c (10/3/2012)


    Jason-299789 (10/3/2012)


    I think its the fact that the Row_number() requires an order by statement thus a sort, rather than an Identity which assigns the number as the data is returned.

    OK. So I would have been 3.5 out of 4. What I don't get is the ISNULL around ROW_NUMBER().:unsure:

    Because if you do: -

    SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS N

    INTO yourTallyTable

    FROM (VALUES(1))a(n);

    Then N is a NULLable column. You want it to be NOT NULL, so include the ISNULL(ROW_NUMBER() OVER(ORDER BY (SELECT NULL)),0)


    --EDIT--

    I think there might be a connect item about it somewhere. . . but can't seem to find it.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/