since I already have a table to use, how can I put that in place of
DECLARE @test-2 TABLE (id INT, val VARCHAR(100));
INSERT INTO @test-2
SELECT 1,'jack,25,A67,91J,67,99' UNION ALL
SELECT 2,'jill,5,8,V3' UNION ALL
SELECT 3,'john,7,D4' UNION ALL
SELECT 4,'bill,66,84';
I tried to just put (select row_number() over (order by name) as id, name + ',' + salesnumbers from thetable;
but I cant see what to put in place of the @test-2 here? if I put the table name in there but it doesnt work.
(
SELECT *
FROM
CROSS APPLY
(SELECT * FROM dbo.DelimitedSplit8K(val, ',')) x
)
I did try it with the declare as is just replacing the select lines with my single select and it works, but looks a bit odd.
otherwise, I am getting the desired results.
Thanks a lot guys.