Reminde me - I wish to write a string including [ ] as part of the text, ???

  • Hi,

    DECLARE @test VARCHAR
    SET @test = '[Copy]-'

    Select @test + 'SomeName'

    I want ...

    [Copy]- SomeName

    But I get

    [SomeName

    Please remind me, I have tried / and \ with no luck

     

  • silly me

    DECLARE @test-2 VARCHAR(8) '**** Change ****

  • Correct, if the length is not explicitly declared, a VARCHAR type variable is defined as being one byte long. 🙂

    https://docs.microsoft.com/en-us/sql/t-sql/data-types/char-and-varchar-transact-sql?view=sql-server-ver15

    varchar [ ( n | max ) ] Variable-size string data.

    When n isn't specified in a data definition or variable declaration statement, the default length is 1. If n isn't specified when using the CAST and CONVERT functions, the default length is 30.

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

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