cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a custom sql server data type into a stored procedure

sdelano
New Contributor II

Given the below sql server procedure definition excerpt. How would we pass in an array of data into this this datatype as the input parameter of the stored procedure. when passing in a straight array of values we get the following error.
“reason”:
“Expected value in type:BUID_LIST for parameter:@BUIDS, but got value:[(‘U00003601’), (‘U00007346’), (‘U00011341’), (‘U00011468’), (‘U00019947’), (‘U00026075’), (‘U00027687’), (‘U00038315’), (‘U00041258’), (‘U00043454’)] in type:ArrayList.”

/*
type dbo.BUID_LIST as TABLE (
BUID nvarchar(20) not null
);
go
*/

CREATE PROCEDURE [dbo].[UpdateHousingStudents]
– Add the parameters for the stored procedure here
(@BUIDS dbo.BUID_LIST READONLY,
@Results nvarchar(200) OUTPUT)
AS

BEGIN

1 REPLY 1

Abhishek_Soni37
Contributor

Hi @sdelano

You can pass it as a delimited string, then while the SP gets executed you can use SQL function STRING_SPLIT() and use it.

I hope this helps.

Cheers!