Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

SQL Substring Maximum Allowable Length?

Posted on 2014-08-13
3
Medium Priority
?
187 Views
Last Modified: 2014-08-13
I'm working on an existing stored procedure which uses Substring like so. I need to know what the limit is, 4000?

SELECT
                SUBSTRING
                             ( ( SELECT Names
                                 FROM    table1
                                 FOR XML path(''), elements), 1, 4000)
0
Comment
Question by:WorknHardr
3 Comments
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 1200 total points
ID: 40258764
There does not appear to be a maximum as the function can be used with VARCHAR(MAX) and VARBINARY(MAX).

http://msdn.microsoft.com/en-us/library/ms187748.aspx
The values for start and length must be specified in number of characters for ntext, char, or varchar data types and bytes for text, image, binary, or varbinary data types.
The expression must be varchar(max) or varbinary(max) when the start or length contains a value larger than 2147483647.
0
 
LVL 1

Expert Comment

by:gireeshbabu
ID: 40258776
I guess no limit on that.
0
 

Author Closing Comment

by:WorknHardr
ID: 40258861
thx
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question