I know there are probably 20 different ways of doing this but I'm new at pass through queries so I want to learn the proper syntax. I have a stored procedure that counts the amount of e-mail addresses on file for a particular employee. Basically a fast version of DCount("ID", "EMAILS", "EMPLOYEEID = " & ID).
Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[EmployeeEmailCount]
@EMPID as bigInt, @EMPCount as Int Output
AS
BEGIN
SET NOCOUNT ON;
SELECT @EMPCount = Count(*) From EmployeeContactEmails where EmployeeID = @EMPID
END
I created as simple pass through query:
Code:
exec "employeeemailcount" @EMPID = 6
This should return 2 but I get an error:
Code:
Procedure of Function 'EmployeeEmailCount' expects parameter '@EMPCount', which was not supplied"
If I just add @EMPCount to the end of the query it tells me I have to declare the scalar value @EMPCount. How should the syntax read for the output variable?
Thanks in advance