|
CREATE PROCEDURE [dbo].[FindEmployeeRecord]
@EmployeeID nvarchar(Max)
AS
BEGIN
DECLARE @sqLQuery VARCHAR(MAX)
Declare @AnswersTempTable Table
(
EmpId int,
EmployeeName nvarchar (250),
EmployeeAddress nvarchar (250),
PostalCode nvarchar (50),
TelephoneNo nvarchar (50),
Email nvarchar (250),
status nvarchar (50),
Sex nvarchar (50)
)
Set @sqlQuery =
'select e.EmpId,e.EmployeeName,e.Email,e.Sex,ed.EmployeeAddress,ed.PostalCode,ed.TelephoneNo,ed.status
from Employee e
join EmployeeDetail ed on e.Empid = ed.iEmpID
where Convert(nvarchar(Max),e.EmpId) in ('+@EmployeeId+')
order by EmpId'
Insert into @AnswersTempTable
exec (@sqlQuery)
select * from @AnswersTempTable
END
Call Procedure-
exec FindEmployeeRecord('1,2,3,5,4,6,7')
modified 1-Jul-20 15:05pm.
|
|
|
|