Given this EXACT ad-hoc query:
DECLARE @list AS TABLE (Name VARCHAR(20))
INSERT INTO @list(Name)
VALUES ('Otter', 'Lebron', 'Aaron', 'Brock')
SELECT *
FROM Users
WHERE FirstName in (SELECT Name from @list)
How can this be done using C# ADO.NET with a SqlParameter?
I’m using a modification of your orginal SQL for sample purposes.
You can use a Table-Valued Parameter
Here’s a modified example taken from Table-Valued Parameters in SQL Server 2008 (ADO.NET)
But you need to define the type dbo.Names before it can work
Here’s the type creation SQL
Another option is to use an XML Parameter