I unable to create procedure , i have getting mention error.
Msg 156, Level 15, State 1, Procedure spx_GetEmployees, Line 3 Incorrect syntax near the keyword 'NULL'. Msg 137, Level 15, State 2, Procedure spx_GetEmployees, Line 12 Must declare the scalar variable "@From". Msg 137, Level 15, State 2, Procedure spx_GetEmployees, Line 16 Must declare the scalar variable "@From". Msg 137, Level 15, State 2, Procedure spx_GetEmployees, Line 20 Must declare the scalar variable "@From
CREATE PROCEDURE spx_GetEmployees
@Filter VARCHAR(50),
@From DATETIME NULL,
@To DATETIME NULL
AS
BEGIN
SET NOCOUNT ON;
IF @Filter = 'ALL'
SELECT EmployeeID, FirstName + ' ' + LastName 'Name', City, Country
FROM Employees
WHERE (BirthDate BETWEEN @From AND @To) OR (@From IS NULL OR @To IS NULL)
ELSE IF @Filter = '5'
SELECT TOP 5 EmployeeID, FirstName + ' ' + LastName 'Name', City, Country
FROM Employees
WHERE (BirthDate BETWEEN @From AND @To) OR (@From IS NULL OR @To IS NULL)
ELSE
SELECT EmployeeID, FirstName + ' ' + LastName 'Name', City, Country
FROM Employees
WHERE Country=@Filter AND (BirthDate BETWEEN @From AND @To) OR (@From IS NULL OR @To IS NULL)
END
GO
==========
CREATE TABLE "Employees" (
"EmployeeID" "int" IDENTITY (1, 1) NOT NULL ,
"LastName" nvarchar (20) NOT NULL ,
"FirstName" nvarchar (10) NOT NULL ,
"Title" nvarchar (30) NULL ,
"TitleOfCourtesy" nvarchar (25) NULL ,
"BirthDate" "datetime" NULL ,
"HireDate" "datetime" NULL ,
"Address" nvarchar (60) NULL ,
"City" nvarchar (15) NULL ,
"Region" nvarchar (15) NULL ,
"PostalCode" nvarchar (10) NULL ,
"Country" nvarchar (15) NULL ,
"HomePhone" nvarchar (24) NULL ,
"Extension" nvarchar (4) NULL ,
"Photo" "image" NULL ,
"Notes" "ntext" NULL ,
"ReportsTo" "int" NULL ,
"PhotoPath" nvarchar (255) NULL
)