Home Forums SQL Server 2005 Development Difference between varchar(max) and varchar(8000) RE: Difference between varchar(max) and varchar(8000)

  • charlesz (2/2/2009)


    Second, NVarchar(MAX) and Varchar(MAX) can only hold up to 65535 bytes ( The number posted by Gail Shaw was wrong).

    Any bets on that?

    DECLARE @test-2 VARCHAR(MAX),

    @String VARCHAR(MAX)

    SELECT @test-2 = '',

    @String = '1234567890'

    ;WITH

    cteTally AS

    (--==== Create a Tally CTE from 1 to 10,000

    SELECT TOP (10000)

    ROW_NUMBER() OVER (ORDER BY t1.ID) AS N

    FROM Master.sys.SysColumns t1

    CROSS JOIN Master.sys.SysColumns t2

    )

    SELECT @test-2 = @test-2 + '1234567890'

    FROM cteTally

    SELECT LEN(@Test)

    I have to ask... where did you get such an idea? I'd like to know so I can go straighten them out. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)