.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Split function for String in SQL Server

Posted By: Narayanan     Posted Date: May 03, 2013    Points:5   Category :Sql Server
Hi all,
This is my query,How to split Numbers from string.I need a function for this task.


Responses
Author: Narayanan             
Posted Date: May 09, 2013     Points: 20   

Hi All,
finally, I got it . This is the function for split integer from string

CREATE FUNCTION ExtractInteger(@String VARCHAR(2000))
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE @Count INT
DECLARE @IntNumbers VARCHAR(1000)
SET @Count = 0
SET @IntNumbers = ''

WHILE @Count <= LEN(@String)
BEGIN
IF SUBSTRING(@String,@Count,1) >= '0'
AND SUBSTRING(@String,@Count,1) <= '9'
BEGIN
SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1)
END
SET @Count = @Count + 1
END

RETURN @IntNumbers
END
GO


Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Anna Harris             
Posted Date: May 14, 2013     Points: 20   

I was searching for this split function in SQL since a very long time. Thanks for sharing the information.

Author: Deco             
Posted Date: May 27, 2013     Points: 20   

World smallest split string function is available in the below URL

http://www.dotnetbites.com/split-strings-into-table

Regards,
Deco
Author: Anna Harris             
Posted Date: June 04, 2013     Points: 20   

The code that Narayanan has shared is the best example of splitting integers from a given string.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend