0

I am looking a way to find out comma in a string in where clause.

DECLARE @List VARCHAR(max) = 'Hi, going, home for now'
SELECT 
@List = COALESCE(@List + ',')
fname
  FROM [dbo].[table]
where  fname IN ( @List)
Aarav
  • 3
  • 5
  • What is the version of `SQL Server` you are using ? – Squirrel Feb 02 '21 at 01:52
  • Please [edit] your post to add a tag for the specific DBMS you're using, as syntax and functionality differs widely between them. Without that information, anyone wanting to answer may be wasting their time, because they might post an answer for one DBMS only to find you're using something else where it won't work. The description of the SQL tag you used strongly suggests that you also add a tag for the specific DBMS. Please don't ignore that advice. – Ken White Feb 02 '21 at 01:53
  • @Squirrel, `SQL Server Version 17.2` – Aarav Feb 02 '21 at 03:39
  • @KenWhite, Thank you for your advice. I have edited the question and added the DBMS in it. – Aarav Feb 02 '21 at 03:40
  • I am not sure why it marked duplicate. The answer does not relate to my question. – Aarav Feb 02 '21 at 04:09
  • 1
    That answer does exactly what you asked. You should read it again. – Ken White Feb 02 '21 at 05:11

0 Answers0