Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kka_anand
Starting Member
24 Posts |
Posted - 2010-08-08 : 15:40:04
|
Hi All,I have taken the below code from the following link http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648CREATE FUNCTION dbo.Split( @RowData nvarchar(300), @SplitOn nvarchar(1)) RETURNS @RtnValue table ( Id int identity(1,1), Data nvarchar(100)) AS BEGIN Declare @Cnt int Set @Cnt = 1 While (Charindex(@SplitOn,@RowData)>0) Begin Insert Into @RtnValue (data) Select Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1))) Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData)) Set @Cnt = @Cnt + 1 End Insert Into @RtnValue (data) Select Data = ltrim(rtrim(@RowData)) ReturnENDwhen I execute the function,select * from Split('1,22,333,444,5555,666', ',')it displays the result asId Data1 12 223 3334 4445 55556 666It's possible to filter the result with a condition?display the result for the Id=3.i.e Id Data3 333RegardsAnand |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-08 : 17:14:58
|
select * from Split('1,22,333,444,5555,666', ',') as wwhere id = 3 N 56°04'39.26"E 12°55'05.63" |
 |
|
kka_anand
Starting Member
24 Posts |
Posted - 2010-08-09 : 04:01:13
|
Thanks...Peso.I want the filter condition inside the fuction. |
 |
|
|
|
|
|
|