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

Split list into a table

$
0
0

I'm trying to create a SQL stored procedure that will receive 3 lists from a VBA program.  I want to split the lists whose items are divided by commas and put the list items into a single table that has a primary key to automatically generate numbers.  I get an error about the object "split" when using the following:

Program recieves 3 lists whose order should be the same, so that the first item on the pNameList should end up in the same row of the table as the first items in the jNameList and kNameList:

@pNameList nvarchar(max)

@jNameList nvarchar(max)

@kNameList nvarchar(max)

CREATE TABLE #combinedTbl (cID INT IDENTITY(1, 1) PRIMARY KEY, pName nvarchar(255), jName nvarchar(255), kName nvarchar(255))

(Now, how do I get the values into the table?)
(I tried just inserting the values from one list into a smaller, 2-column table with ID and pName, but got an error about the term "split" or "dbo.split," trying both)

INSERT INTO #pNameTbl SELECT * FROM split(@pNameList)

Any thoughts?   I read that "split" is an SQL term on one website, but perhaps it's not?


Gina



Viewing all articles
Browse latest Browse all 23857

Trending Articles



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