• Shaun McGuile (2/2/2009)


    Hugo: so what you are saying is that REPLICATE uses varchar sizing i.e. 8000 and not the destination size unless you explicitly instruction the function to use something else as shown in your code. 😉

    Dumb function ! 😛

    Hi Shaun,

    I'd use different words, but basically you're right.

    And by the way, this is not limited to REPLICATE but applies to all expressions in SQL Server. The division below discards the fraction because the dividend of two integers is defined to be an integer, regardless of whether the result will later be assigned to a float variable.

    DECLARE @i1 int, @i2 int, @f1 float;

    SET @i1 = 10;

    SET @i2 = 3;

    SET @f1 = @i1 / @i2;

    SELECT @f1;

    And as far as I can remember, all other programming languages I have been involved with behave similarly.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/