I'm creating a stored procedure that will take the results of a temp table and check for existence using the IN keyword. The code looks like this:
ALTER PROCEDURE [dbo].[studentBranchLogin]
-- Add the parameters for the stored procedure here
DECLARE @dActive bit;
DECLARE @TT TABLE (dept int, active bit);
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT INTO @TT(dept, active)
SELECT deptid, active FROM srcuDeptId WHERE active = TRUE
-- Insert statements for procedure here
SELECT srcuid FROM srcuLogins WHERE logon = @userName AND password = @userPass AND srcuid IN @TT
I get a Msg 170, Level 15 state 1
Line 24: Incorrect syntax near '@TT'.
So while I'm sure the @TT temp table isn't being read, I find very few resources for answer what the proper syntax should be.
Any assistance is greatly appreciated.
View Complete Post