View Single Post
  #1 (permalink)  
Old 09-29-09, 19:15
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
How to pass a string of interger to a SP with an in() clause

I need to pass a string to my sp but dont know how the EXEC string is below as well as the sp.

--EXEC [spGetUserCompanyUsers] '1,2,3'
ALTER PROCEDURE [dbo].[spGetUserCompanyUsers]
@CompanyIds varchar(50)
AS
BEGIN

SELECT [User].UserId
, [User].UserDesc
, Companies.CompanyId
FROM [User]
INNER JOIN UserCompany ON [User].UserId = UserCompany.UserId
INNER JOIN Companies ON UserCompany.CompanyId = Companies.CompanyId
WHERE Companies.[Name] IN(@CompanyIds)

END
Reply With Quote