I not sure whether is there a way to create/alter a view with variable declare in the same statement. I encounter some error when I run the below statement.
Server: Msg 156, Level 15, State 1, Procedure Employee_Details , Line 2
Incorrect syntax near the keyword 'DECLARE'.
Server: Msg 170, Level 15, State 1, Procedure Employee_Details , Line 16
Line 16: Incorrect syntax near ')'.
My SQL Statement
ALTER VIEW Employee_Details as (
DECLARE @usr nvarchar(250)
SET @usr = user
EMPLOYEE AS E
E.DEPARTMENT = (SELECT *
The GetCurrentUser is a function I have create to get the department that the user can view.
Please advice. Thanks in advance.