For retreving commma seperated values for a specific paramenter or column
If you want to retrieve comma seperated values instead of all values in multiple line.
then first set the values to varchar.. eg if you have a parameter which you want to retrieve comma seperated values for this parameter then initilize it as varchar.eg
@ProjectID varchar(25), @RegistrationNo varchar(25)
then in where clause use function "select item from fn_split" and pass your parameter which you want to split as the first argument of this function and pass an operator as second argument on which you want to spit value eg.
where
(Project.intProjectID in (select item from fn_split(@ProjectID, ','))) and
(Student.intRegNo in (select item from fn_split(@RegistrationNo, ',')))
This is a sql server built in function
"select item from fn_split"
then first set the values to varchar.. eg if you have a parameter which you want to retrieve comma seperated values for this parameter then initilize it as varchar.eg
@ProjectID varchar(25), @RegistrationNo varchar(25)
then in where clause use function "select item from fn_split" and pass your parameter which you want to split as the first argument of this function and pass an operator as second argument on which you want to spit value eg.
where
(Project.intProjectID in (select item from fn_split(@ProjectID, ','))) and
(Student.intRegNo in (select item from fn_split(@RegistrationNo, ',')))
This is a sql server built in function
"select item from fn_split"
Comments
Post a Comment