r/SQL • u/hellorchere • Jun 26 '26
SQL Server SQL Indentation
I am working on MS SQL. I have got few scripts of 1000+ line with poor indentaion.
Any tool which i cna use to properly format it.
Please suggest
25
Upvotes
28
u/Aggressive_Ad_5454 Jun 26 '26
SSMS has a Format Source Code option.
Notepad++ has a plugin to do that as well.
I use them as a starting point.
11
u/Brian_MPLS Jun 26 '26
https://poorsql.com/
2
u/Not-Inevitable79 Jun 26 '26
I like the formatting available in Devart SQL Complete. You can customize it to your liking.
2
u/mtetrode Jun 26 '26
DataGrip for this and thousands of other things
2
u/Arkanejl Jun 27 '26
I had this same issue when moving from Oracle SQL Developer to SSMS. SQL Developer had a lot of inbuilt options for formatting code and it was a shame that SSMS didn't offer anything similar.
I couldn't find a solution that I liked so I just use a dedicated chat in Co-Pilot with clear and specific instructions for how I want my code formatted. It's the best bespoke option for me in the end.
4
u/billbot77 Jun 26 '26
Funny, in theory these formatting tools should be helpful - but I have found that reformatting by hand helps me to slow down and read the sql properly. Automating the process would ironically slow me down in the overall job.
...or at least that's what I tell myself. Fixing up SQL to my personal (and admittedly unusual) preferred style by hand sometimes becomes compulsive, ngl
1
u/N_arwhal Jun 26 '26
With all my heart, I recommend Redgate SQL Prompt. Among many amazing features, it offers customizable code formatting. It's paid though, but its a gamechanger for people working with SQL.
1
u/theacez Jun 26 '26
I use VS Code for all my formatting.
1
u/DrWisonsBrother Jun 26 '26
Redgate if you can afford the license.
1
u/petdance Jun 26 '26
I use “sleek”.
1
u/jaxjags2100 Jun 28 '26
Claude
1
u/Photizo Jun 30 '26
python sql-formatter
1
u/bmckay1987 Jul 05 '26
100% give this to Claude or Gemini to solve.
1
u/dbxp Jun 26 '26
Point copilot at the folder and have it do them all at once
0
u/Wooden-Debate-2878 Jun 27 '26
How can someone,( a friend 👀) SQL inject or an equivalent to a better grade? Third wold country so there are no strict cyber crime laws and it's a pretty old uni where can she start. Knowing the kind of dB the results are stored in?
-9
u/asisoid Jun 26 '26 edited Jun 26 '26
Honestly, I just use Gemini for SQL formatting. Unlike using notepad++ or built in ssms tools, if you don't like how it's formatted, tell it do try again with specific requests.
Any AI tool will be a good option
-1
u/Delicious-Expert-936 Jun 26 '26
Gemini/ Claude
0
u/[deleted] Jun 26 '26
[deleted] — view deleted comment
7
u/[deleted] Jun 26 '26
[removed] — view removed comment