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)

Split function with store procedure

By Luis Atondo,

This function returns the value indicated in a string separated by a character in particular, like a split function in Visual basic.

Note: 1st value in string is 0.

Ex. 1:

SET @Result='1~Example Text~5'
EXEC SplitString1 @yourString = @Result,@Delimiter = '~',@ReturnVal =0, @Result = @Result OUTPUT
SELECT @Result as Result

Returned Value='1'

Ex 2:

SET @Result='Value1~Value2~Value3~Value4'
EXEC SplitString1 @yourString = @Result,@Delimiter = '~',@ReturnVal =2, @Result = @Result OUTPUT
SELECT @Result as Result

Returned Value='Value3'

Total article views: 1725 | Views in the last 30 days: 7
 
Related Articles
FORUM

Return result of dynamic query from function

Return result of dynamic query from function

FORUM

Correlated sub query takes more time to return result

Correlated sub query takes more time to return result

FORUM

Select statement of view stays 5 hours to return results......

Select statement of view stays 5 hours to return results......

FORUM

a simple? MDX query returning top 10 and rest result

MDX query returning top 10 and rest result

FORUM

Hashbytes function returning unexpected results

SQL 2005 HASHBYTES UNEXPECTED RESULTS

Tags
charindex    
split    
stored procedures    
 
Contribute