October 6, 2018 at 10:25 pm
Comments posted to this topic are about the item QUOTENAME lengths
October 6, 2018 at 10:26 pm
Good question to start the week, thanks Steve.
...
October 7, 2018 at 11:08 pm
Nice, easy question to start the week on, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
October 8, 2018 at 1:45 am
Easy to answer. But actually a bit weird and impractical then, that the return type is nvarchar(258).
October 8, 2018 at 4:44 am
morlindk - Monday, October 8, 2018 1:45 AMEasy to answer. But actually a bit weird and impractical then, that the return type is nvarchar(258).
This actually makes sense. QUOTENAME is really for quoting an object's name. Object names use the datatype sysname (which is a synonym for nvarchar(128)), and that is actually the expected input type for QUOTENAME too. 258 is 128 x 2 + 2, which means that it can handle every possible object name. The +2 handles the brackets ([]) at either end, and the x2 handles the escape characters. Thus, if someone was (foolish) enough to create an object with 128 ]'s, QUOTENAME would be able to return the correct value:
SELECT QUOTENAME(REPLICATE(N']',128));
Which returns a 256 ]'s enclosed by brackets ([]).
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
October 8, 2018 at 7:03 am
Thom A - Monday, October 8, 2018 4:44 AMmorlindk - Monday, October 8, 2018 1:45 AMEasy to answer. But actually a bit weird and impractical then, that the return type is nvarchar(258).This actually makes sense. QUOTENAME is really for quoting an object's name. Object names use the datatype sysname (which is a synonym for nvarchar(128)), and that is actually the expected input type for QUOTENAME too. 258 is 128 x 2 + 2, which means that it can handle every possible object name. The +2 handles the brackets ([]) at either end, and the x2 handles the escape characters. Thus, if someone was (foolish) enough to create an object with 128 ]'s, QUOTENAME would be able to return the correct value:
SELECT QUOTENAME(REPLICATE(N']',128));
Which returns a 256 ]'s enclosed by brackets ([]).
+1
Super explanation. Thanks, Thom.
October 9, 2018 at 2:34 am
Nice question and great additional info from Thom
---------------------------------------------------------------------------------------
The more you know, the more you know that you dont know
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply