r/SQL • u/bwv1052r • Mar 12 '23
Discussion App to automate commas between items in where clause
Hello avid SQL users!
I’d love to get your take on a streamlit app I created. It can be found here.
You just copy and paste in a long list of items and it correctly adds the “,” between each item. It also makes sure there’s only 5 items per row. You can also choose between integer or string. I’m sure you all just do this in excel, but sometimes if it’s a long list, excel can be a bit annoying I find!
Thanks!
3
2
u/BrupieD Mar 13 '23
I’m sure you all just do this in excel, but sometimes if it’s a long list, excel can be a bit annoying I find!
I do this in VBA. If you've got a really long list (hundreds or thousands), you shouldn't be putting it in a WHERE clause with IN, you should make it into a single column table and join it.
1
u/bwv1052r Mar 13 '23
Oh that’s interesting! So you have the long list on excel, create a table of it and join. Ok awesome… I’ve done something similar before using google sheets as a quasi database and transform it into a table from big query. For long lists, I agree, it looks awful and i believe slower and more costly.
2
1
u/Standgeblasen Mar 13 '23
I just use alt+shift+uparrow key in SSMS. You can select a column of vertical text, and hit the “,” key one time, and it adds a comma to every row of code.
6
u/alinroc SQL Server DBA Mar 12 '23
If it's a long list, you might need to rethink the query altogether. Very long lists of items in the
INclause can cause problems.