Add new substring function where third parameter is end and not length - by Erland Sommarskog

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 258728 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 2/18/2007 1:16:45 PM
Access Restriction Public


Many languages have a substring function, either built-in or in the standard 
library. All have the string as the first parameter, and the second parameter
is always where the second string starts. But for the third parameter there is a
mix: some go with closing position, other languages requires you to specify the 
length of the substring. T-SQL is of the latter school.

Depending on context both methods can be preferable. I have however
found that in T-SQL using substring can be quite bulky to use because of 
the last parameter. For instance, consider extracting the SQL statement
for a query from dm_exec_query_stats and dm_exec_sql_text. query_stats
returns two offsets, and not a start and a length.
Sign in to post a comment.
Posted by Microsoft on 10/12/2007 at 1:31 PM
Hi Erland,

This seems like a specific example of a more general request we get to provide a much richer set of built-in functionality than we currently do. As a rule, we don't seem so good at providing them---especially where they can be resolved with some variation of "you can already do that by [some clunky workaround]"---but I'd like to figure out how to do better here.

I'm pushing this request to the Katmai+1 release at this point, but we'll keep it in mind.

Thanks for the request,