I am trying to look on the web for a way to create a stored procedure that I can run and then put in multile values and this is the closest I can find:

CREATE TYPE dbo.EmployeeList
AS TABLE
(
  EmployeeID INT
);
GO

CREATE PROCEDURE dbo.DoSomethingWithEmployees
  @List AS dbo.EmployeeList READONLY
AS
BEGIN
  SET NOCOUNT ON;

  SELECT EmployeeID FROM @List; 
END
GO

Is it possible? I want to create this procedure so that I can run it on my machine for reporting purposes and be able to put in one employee ID or multilpe and it still works? and I will not need to create a separate stored procedure per report.

Recommended Answers

All 2 Replies

I should add that once you have your stored procedure written correctly, you call it and add the required parameters to the command object as you normally would to pass parameters for a normal SQL command.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.