I've Created a SQL Procedure as follows.
Code:
Create Proc spGetEmpDetails
@Id int,@Name varchar(30) OUT,
@Sal integer OUT,@DepName varchar(30) OUT,
@Location varchar(30) OUT
AS 
BEGIN
	Select @Name = t1.Name, @Sal= t1.Salary,
	@DepName = t2.DeptName,	@Location = t2.Location 
	FROM tblEmployee t1
	INNER JOIN tblDepartment t2
	ON  t1.DepId = t2.Id
	WHERE t1.ID = @Id
END
I'm executing it as
Code:
 Declare @Name nvarchar(30),@Sal integer,@Dep nvarchar(25),@Loc nvarchar(25)
 EXEC spGetEmpDetails @Id=5,@Name OUT,@Sal OUT,@Dep OUT,@Loc OUT
 Select @Name as Name,@Sal as Salary,@Dep as DepartmentName,@Loc as Location
I'm getting an error like : Must pass parameter number 2 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'.

Shouldn't I give the First Parameter Name when supplying it as input value with other OUT Parameters ? We doesn't need to maintain order when giving parameter names with values,Right ? If So, when i tried giving @Id =5 as last Parameter like
Code:
Declare @Name nvarchar(30),@Sal integer,@Dep nvarchar(25),@Loc nvarchar(25)
EXEC spGetEmpDetails @Name OUT,@Sal OUT,@Dep OUT,@Loc OUT,@Id=5
Select @Name as Name,@Sal as Salary,@Dep as DepartmentName,@Loc as Location
I'm getting an error like : he formal parameter "@Id" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output. (1 row(s) affected)
Name | Salary|DepartmentName| Location
NULL | NULL |NULL | NULL


Worked fine when executing it as
EXEC spGetEmpDetails 5,@Name OUT,@Sal OUT,@Dep OUT,@Loc OUT
Where did i went wrong ?