Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I search for a ', ' and replace with ', '<CR><LF> in SQL Server Management Studio's editor

I have a long query that I'd like to replace the , with a carriage return to put all the fields on their own line but I can't figure out how to do it in the editor. It wont be fool proof, but better than doing it by hand.

like image 477
Allen Stoner Avatar asked Oct 12 '09 18:10

Allen Stoner


People also ask

How do you do find and replace in SQL Server?

On the Edit menu, point to Find and Replace, and then click Quick Find to open the dialog box with find options, but without replace options. On the Edit menu, point to Find and Replace, and then click Quick Replace to open the dialog box with both find options and replace options.

How do I match a substring to a string in SQL?

The LIKE predicate operator can be used to find a substring into a string or content. The LIKE operator combined with % and _ (underscore) is used to look for one more characters and a single character respectively. You can use % operator to find a sub-string.


Video Answer


2 Answers

CTRL+H

Find what: ', ' (No Quotes) Replace With: ', \n' (No Quotes) 

Expand the Find options and tick the Use Regular Expressions checkbox.

like image 181
Jason Punyon Avatar answered Sep 23 '22 23:09

Jason Punyon


do a find/replace. you want to find a , and replace with a ,\n (new line). to use \n check the box at the bottom called "Use:" and then from the dropdown choose "Regular expressions".

like image 43
thomas Avatar answered Sep 24 '22 23:09

thomas