I wish to set a condition while making use of the WHERE clause basis @USER_ID input recorded from the user in my SQL server query, but I guess I am missing something essential here.
DECLARE @USER_ID NVARCHAR(255) = 'a,b,c' -- will be multi-select parameter; can be null as well
select * from <table_name>
{
if: @USER_ID is NULL then no WHERE condition
else: WHERE <table_name>.<col_name> in (SELECT item FROM SplitString(@USER_ID,','))
}
Can someone please help here?
Aucun commentaire:
Enregistrer un commentaire