Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Extract values from a string using a delimiter

By Tim Sneller,

There are many occasions in programs where you need to manipulate strings of characters that are delimited by a particular character, such as a comma, or a space. This function enables you to extract a substring from the string at a specified occurence of the delimter.

declare @Data varchar(255)
set @Data = 'A,B,C,D,E'
print dbo.field(@data,',',2,2)

Result:-
B,C

Total article views: 2446 | Views in the last 30 days: 4
 
 
Contribute