USE AdventureWorks2012
GO
CREATE
TABLE
Employee_Detail(Id
VARCHAR
(20),
Name
(60),Designation
(80),Salary
BIGINT
)
INSERT
Employee_Detail
SELECT
1,
'Sathya'
,
'VP'
'10000'
2,
'Sunny'
'Manager'
'4000'
3,
'Deepak'
'Senior Programmer'
'2500'
4,
'Lexi'
'Programmer'
'1000'
5,
'Sasha'
PROCEDURE
Get_EmployeeDetails
@EmpIds
(20)
AS
BEGIN
*
FROM
WHERE
CHARINDEX(Id,@EmpIds) > 0
END
EXEC
'1,2'
'3,4,5'
',2,'
Id
Hi Naomi,
Thanks for your valuable suggestion , I had given sizing , considering this example - here there are only 5 Ids
Hi Naomi ,
Thanks for your suggestion , I had given sizing considering this example , here there is only 5 Ids .
CHARINDEX is a poor performing solution and also why we're only using VARCHAR(20)? How many Ids will fit into VARCHAR(20)?
Kindly note that the above suggested method in this post will work only for single character multi-valued parameter :)
good job