sql - “Must declare the table variable” Error with CTE -
When I use a table variable inside a CTE in SQL Server 2005, I am getting the following errors. When I use a physical table, it works fine.
The table variable should declare "@Employee".
'wrong syntax')
Code:
@Emploee table (EmpID INT, EmpName VARCHAR (50), Department VARCHAR (5), Manager INT) @Emploee value (1, 'A', zero, zero) in the @Emploee insert value (2, 'B', 'D100', zero); With EmployeeManagers (select e.EmpId, e.EmpName, e level, e.Manager, e.Empid CurrLevelEmpid, as cast (void as vortar (5)) from department @Employee e.Manager is not e Select zero unions all em.EmpId, em.EmpName, level as level 1, e.Manager, e.Empid CurrLevelEmpID, e.Dept Department EmployeeManagers join them, Employee E on E. Amped = M. Manager) Select Employee Employee
How can we fix this error?
Context
Comments
Post a Comment