Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 1676 | Views in the last 30 days: 6
 
Related Articles
FORUM

Return result of dynamic query from function

Return result of dynamic query from function

FORUM

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

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

FORUM

Correlated sub query takes more time to return result

Correlated sub query takes more time to return result

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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones