Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Use of function

$
0
0
I have a table with this records:
linknumber history
110 46,57,89
220
50
330 22
440 10,12
I want to have this result:
rownumber linknumber
history
1 110 46
2 110 57
3 110 89
4 220 50
5 330 22
6 440
10
7 440 12
and I have this function for split(camma):
ALTER FUNCTION
[dbo].[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

but I don,t know how to use this function in T-sql for
my favorir result?plaese guide me how do I do this?thanks

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>