My stored procedure do not have parameters. Running it as below:-
EXEC sp_Email_spd_CasualNotification
Returns a table:-
DeptChangeID| oldDeptID |DeptID | JobID |EmpID
33419 | NULL | 679 | 3742 |16575
42392 | NULL | 783 | 4742 |100000378
I want to view this table in View. I just can't find a way. What I meant was
CREATE View [dbo].[vw_EmploymentLatest] as
Select * from (EXEC sp_Email_spd_CasualNotification)
This is not possible.
My stored procedure simplified as below:-
declare @empTable table (employeeID int)
declare @selectedDeptChangeIDTable table (deptChangeID int)
declare @rowCount int
declare @rowNum int
declare @selectedDeptChangeID int
declare @empID int
Insert into @empTable (employeeID)
SELECT DISTINCT
E.Employee_ID
FROM Employee E
'
'
WHILE exists (select * from @empTable)
BEGIN
SELECT @empID = (select top 1 employeeID from @empTable order by employeeID asc)
'
'
WHILE @rowNum <= @rowCount
BEGIN
declare @p1 int
declare @p2 int
'
'
'
'
DELETE @empTable WHERE employeeID = @empID
END
Select * from Employment Where DeptChangeID in (Select deptChangeID from @selectedDeptChangeIDTable)