Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i pass the parameter to stored procedure as string "RET:WHO:IMP:XMP"
now i wane to split this string as different string RET WHO IMP XMP. how can I?
Posted

 
Share this answer
 
Comments
Monjurul Habib 4-Jul-11 15:02pm    
nice link, my 5.
Here more than couple of ways

Split String in SQL[^]
 
Share this answer
 
Comments
Monjurul Habib 4-Jul-11 15:02pm    
nice link, my 5.
This link-SQL Server Split Function[^] might help you.
 
Share this answer
 
Comments
Monjurul Habib 4-Jul-11 15:03pm    
nice link, my 5.
Another link here
 
Share this answer
 
Try this link, hope this will be helpful for you.

http://sharmanuj.blogspot.in/2014/07/how-to-split-string-in-sql-server.html[^]
 
Share this answer
 
Hi,

Try This

SQL
CREATE FUNCTION [Split]
	(
		@String varchar(8000),
		@Delimiter char(1)
	)     
	returns @temptable TABLE (items varchar(8000))     
	as     
	begin     
		declare @idx int     
		declare @slice varchar(8000)     
	    
		select @idx = 1     
			if len(@String)<1 or @String is null  return     
	    
		while @idx!= 0     
		begin     
			set @idx = charindex(@Delimiter,@String)     
			if @idx!=0     
				set @slice = left(@String,@idx - 1)     
			else     
				set @slice = @String     
			
			if(len(@slice)>0)
				insert into @temptable(Items) values(@slice)     
 
			set @String = right(@String,len(@String) - @idx)     
			if len(@String) = 0 break     
		end 
	return     
	end


And

SQL
SELECT * from Split('RET:WHO:IMP:XMP',':')


Hope this will help you.

Cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900