varchar(max) with QUOTENAME

  • When I use QUOTENAME with varchar(max), it is giving me error

    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

    SET @test-2= QUOTENAME(@Test,'''')

    SELECT LEN(@Test)

  • Boooks online says a the argument expects a varchar/nvarchar(128) for the max size.

    QUOTENAME ( 'character_string' [ , 'quote_character' ] )

    Arguments

    'character_string'

    Is a string of Unicode character data. character_string is sysname and is limited to 128 characters. Inputs greater than 128 characters return NULL.

    'quote_character'

    Is a one-character string to use as the delimiter. Can be a single quotation mark ( ' ), a left or right bracket ( [ ] ), or a double quotation mark ( " ). If quote_character is not specified, brackets are used.

    Return Types

    nvarchar(258)

    Examples

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you very much. I just jumped without checking book online.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply