I have a very long list of codes for a WHERE statement in SQL Server that I would like to 'quickly' add quotes around each one and a comma at end of each one.
I would like to take the huge list like this (with 100's of them in my WHERE)
WHERE CODE IN
(P279273
Q2793567
Q29262718)
and 'quickly' insert quotes and commas like this (doing it directly in SQL)
WHERE CODE IN
('P279273',
'Q2793567',
'Q29262718')
Anyone know how to insert those in quickly in SQL Server directly without manually going line by line (and not doing it in Excel first)?
2条答案
按热度按时间ig9co6j11#
Just another option
Example
Results
qnzebej02#
First get a line-separated list of your elements.
Ctrl + Alt
(Shift + Alt
for Visual Studio/SSMS) anddown arrow
to make multiple cursors for each line.Ctrl
and press theright arrow
(orEnd
if one or more lines has spaces in the words) to move to the right side of the keyword. Insert another single quote and a comma.WHERE IN ()
Article on this - https://www.sqlservercentral.com/blogs/quick-tip-quickly-bulk-edit-lines-in-ssms