Click here to Skip to main content
14,869,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to pass in clause using store procedure...

What I have tried:

I have tried 2 queries
SELECT LOGIN_ID FROM VW_MS_USER WHERE TL_No IN (@TL_No)

2.
RM_Number IN (SELECT RM_Number FROM dbo.sample_Split(@TL_No, ','))
Posted
Updated 20-Nov-20 7:29am
v3

Attempt 1 will only work if you are using Dynamic SQL - there is an example of that in the link in Solution 1
Attempt 2 has a good chance of working if your function dbo.sample_Split returns a table (also on the link in Solution 1), but note that it not very likely that it will will return a column called RM_Number .. Returning value is more likely. Try
SQL
WHERE RM_Number IN (SELECT value FROM dbo.sample_Split(@TL_No, ','))
Or, to find out the name of the column that is actually returned run
SQL
SELECT * FROM dbo.sample_Split(@TL_No, ',')
in SSMS and examine the results. Replace "value" in my example with the column name that your function returns.

Why not just use the built-in SQL Function STRING_SPLIT[^]? (returns a column value)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900