I have 5 facilities in my division, but the code below in a stored procedure only pulls documents when the "facilityID = 4" unless if I change it manually to represent other ID numbers. So I need the facilityID variable below to point to more than one value like:
[Set @FacilityID = 1,2,3,4,5] but of course it's not allowing me. If it was characters, I would be able to put them in quotes. Any advice please?
declare @facilityID tinyint,
@facilitydivisionID tinyint,
SET @facilityID = 4
SET @facilitydivisionID = 6
Best Answer
You can use a table-valued parameter.
Then your stored procedure can say:
Then you can call it from T-SQL like this:
Or from C# using a DataTable and a parameter type as Structured. You can search to find plenty of examples of using TVPs from application code.