Row Over partition in function [Resolved]

Posted by Ramsakthi under Sql Server on 11/20/2014 | Points: 10 | Views : 1271 | Status : [Member] | Replies : 3
Go through Row Over partition also. Also try to create a tabular function, which accepts parameter as ‘1,2,3,4,5,6’ and return as below.

1
2
3
4
5
6

Ramu.R


Responses

Posted by: Bandi on: 11/21/2014 [Member] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
mark the solution post as answered

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Ramsakthi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 11/20/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[ParseValues]
(@String varchar(8000), @Delimiter varchar(10) )
RETURNS @RESULTS TABLE (ID int identity(1,1), Val varchar(50))
AS
BEGIN
DECLARE @Value varchar(100)
WHILE @String is not null
BEGIN
SELECT @Value=CASE WHEN PATINDEX('%'+@Delimiter+'%',@String) >0 THEN LEFT(@String,PATINDEX('%'+@Delimiter+'%',@String)-1) ELSE @String END, @String=CASE WHEN PATINDEX('%'+@Delimiter+'%',@String) >0 THEN SUBSTRING(@String,PATINDEX('%'+@Delimiter+'%',@String)+LEN(@Delimiter),LEN(@String)) ELSE NULL END
INSERT INTO @RESULTS (Val)
SELECT @Value
END
RETURN
END
GO
-- call function to get result
SELECT Val FROM ParseValues( '1,2,3,4,5,6', ',')


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Ramsakthi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ramsakthi on: 11/20/2014 [Member] Starter | Points: 25

Up
0
Down
Thanks a lot.


Ramu.R

Ramsakthi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response