0

If I have a query like this:

Select * from customers where partnerID in (1239
2324
323
4435
524
653
778
....)

Is there any shortcut to add commas between the numbers when "space" is used to separate them? I usually use Excel for this to merge the partnerID with "," and then past it back into SQL. I know there is a find and replace function but I don't know how to find the spaces?

I want:

    Select * from customers where partnerID in (1239,
2324,
323,
4435,
524,
653,
778,
....)
1
  • 1
    SQL Server is a server, it has no UI. Whatever editor you use probably allows multi-line editing. SSMS, Visual Studio Code, Visual Studio and Sublime Text definitely do Commented Sep 11, 2020 at 8:58

2 Answers 2

1

In SQL Server Management Studio you can press ALT and hold it when selecting multiple lines with the mouse. Then you can edit all the lines at once. Like this you need to type one comma only.

Sign up to request clarification or add additional context in comments.

Comments

0

For your query..(if each number is followed by a new line)

in SSMS, Find&Replace (or ctrl+H)

--replace each linebreak with a comma and linebreak

Find what:\n
Replace with:,\n
Find Options: Check Use: Regular Expressions

ref: https://learn.microsoft.com/en-us/sql/ssms/scripting/search-text-with-regular-expressions

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.