Large strings

  • Comments posted to this topic are about the item Large strings

  • This was removed by the editor as SPAM

  • Well, the documentation for nchar and nvarchar still says that the the value can be any number from 1 to 4000 or max, and 5000 is clearly not in that range, so I was actually expecting an error, but that wasn't one of the choices.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • drew.allen (5/26/2016)


    Well, the documentation for nchar and nvarchar still says that the the value can be any number from 1 to 4000 or max, and 5000 is clearly not in that range, so I was actually expecting an error, but that wasn't one of the choices.

    Drew

    How would that apply? Both variables are VARCHAR (or were when I looked at the question).

    Cheers!

  • drew.allen (5/26/2016)


    Well, the documentation for nchar and nvarchar still says that the the value can be any number from 1 to 4000 or max, and 5000 is clearly not in that range, so I was actually expecting an error, but that wasn't one of the choices.

    Drew

    Wrong data types. Here's the correct link: https://msdn.microsoft.com/en-us/library/ms176089.aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Got the answer but misread the question - did not notice the [font="Courier New"]varchar(MAX)[/font] vs [font="Courier New"]varchar(5000)[/font] !

    Lesson repeated: when looking at T-SQL do not overlook details.

  • Jacob Wilkins (5/26/2016)


    drew.allen (5/26/2016)


    Well, the documentation for nchar and nvarchar still says that the the value can be any number from 1 to 4000 or max, and 5000 is clearly not in that range, so I was actually expecting an error, but that wasn't one of the choices.

    Drew

    How would that apply? Both variables are VARCHAR (or were when I looked at the question).

    Cheers!

    :blush: I guess my morning caffeine hadn't totally kicked in, yet. It's a good thing that producing an error wasn't one of the choices.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • I guess my morning caffeine hadn't totally kicked in...

    Heh, been there more times than I'd care to admit 🙂

  • DECLARE @a VARCHAR(max) = REPLICATE('a', 10);

    DECLARE @b-2 VARCHAR(10) = REPLICATE('b', 10);

    SELECT LEN(@a + @b-2);

    Ans : 20

Viewing 10 posts - 1 through 9 (of 9 total)

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