SSMS Settings
To view the generated SQL scripts with proper formatting, you may need to adjust your SQL Server Management Studio settings.
Retain CR/LF on Copy or Save
By default, SSMS may strip carriage returns and line feeds when copying results from the grid or saving to a file. This causes multi-line SQL scripts to appear as a single long line.
Symptom: You copy a script from the results grid and paste it into a new query window, but instead of nicely formatted SQL with line breaks, you get one giant line of text.
How to Fix
- In SSMS, go to Tools → Options
- Navigate to Query Results → SQL Server → Results to Grid
- Check the box: Retain CR/LF on copy or save
- Click OK
Note: This setting only applies to new query windows. You'll need to close and reopen any existing query windows for the change to take effect.
Why This Matters
The optimization suite generates multi-line SQL scripts in the Script column of result sets. These scripts include:
CREATE INDEXstatements with proper formattingDROP INDEXstatementsUPDATE STATISTICScommands- Comments explaining each recommendation
Without the CR/LF setting enabled, these scripts become unreadable single-line strings that are difficult to review and execute.
Alternative: Results to Text
If you prefer not to change the grid settings, you can also use Results to Text mode:
- Press Ctrl+T before running your query (or go to Query → Results To → Results to Text)
- Run your query
- The output will preserve line breaks automatically
To switch back to grid mode, press Ctrl+D.