I use version control and some of my team use Toad, others use SQL Developer. Is there someway to align the two formats?
The reason being that when you compare the versions most of the changes are due to formatting.
In Toad, you use Ctrl + Shift + F
In SQL Developer, you use Ctrl + F7
In SQL Developer it has some other formatting, but nothing for Toad which uses QP5 (Quest Parser Version 5)
You can change how SQL Developer formats your code; from the menu go to:
Tools->Preferences->Code Editor->Format.
Go into Advanced Formatting to configure alignment, line breaks. whitespace etc.
Toad presumably has similar options. You just need to set them up the same, which may need a bit of trial and error to get right.
Related
How do I stop Visual Studion 2017 form auto-formatting my T-SQL code and changing the case of keywords, functions, etc? I want to keep the code exactly as I type it. The only relevant option I see is under Editor - SQL Server Tools - IntelliSense - Casing for built-in functrion names, which does not seem to do anything (I changed it to Lower case, restarted the IDE, but it still converts them to upper case). I did not find anything relevant under the T-SQL90 and U-SQL, and I do not see any other T-SQL specific settings (I'd expect something like Transact-SQL, but there is no such option). Any idea?
Here is the first place which can't be easily found without using the search bar. Also, it's not language specific either unfortunately.
Search for 'format' and turn off 'format as you type' option
Here is the 2nd place I'm aware of
Search for 'pretty' and turn off reformatting
Hope this is helpful -- if you find a SQL specific way to avoid the annoyance please post a response to my answer.
I have been Googling this for sometime and used the question search functionality here before posting.
In SSMS I want to edit the end of each line in the same way ALT + Shift can be used to edit the start of every line.
Notepad++ can achieve this using the replace functionality with a regex condition by specifying $ - end of line. However this seems unreliable and a little buggy.
Ideally I want to achieve this in SSMS I would like one editor that is great for MS SQL and helps my coding productivity.
I have looked into sublime but interfacing with the DB securely or reliably looks problematic.
Anything that avoids be going to the end of 700 lines of code and manually entering the same info would be great.
I am also looking into creating macros with AutoHotkey to improve coding performance.
In SQL Management Studio I found I can carry out a replace and use the reg expression using these params: ".$" . = Matches any single character except a line break. $ = Anchors the match string to the end of a line. This still is'nt ideal as there is no shortcut key but I suppose it works.
Is there a way in SQL SERVER MANAGEMENT STUDIO to highlight all usage of variables when we click on a variable name?
It might not work in all cases, but I find that using the F2 button, which on my machine is mapped to 'View.EditLabel'. It allows me to highlight all of one 'type' things like aliases, variable names and others. Not perfect, but fits my purpose.
I still stand by the fact that it might not be perfect, but it does do what the original poster asked. If you want to see what this command is mapped to see the Options windows.
In the last version of SSMS (currently version 17.1), select the text and type CTRL + F .
No, there's not such feature on SSMS
This has been added in SSMS 2016.
Available for download from https://msdn.microsoft.com/en-us/library/mt238290.aspx
My colleagues using TOAD has a nice feature of a shortcut to queries. For example, they write get_customer_info and the word is replaced by a full joined query. This feature is very nice for productivity. My machine is not licensed to Toad and I use Oracle SQL developer. I wasn't lucky enough to find this feature. I wonder if it has this feature in the first place?
SQLDeveloper has code templates for commonly used statements (see Tools > Preferences > Database > SQL Editor Code templates ). Then there are Snippets ( View > Snippets ) that can be dragged to existing code in the worksheet. It has also some built-in constructs (FOR, IF, etc.) that can be called with CTRL+SPACE if you start typing the statement. You could technically imitate TOADs behavior with the code templates and create templates for statements that you use often. I'm not sure if this even compares to TOADs capabilities, but that's pretty much all you have available in SQLDeveloper.
You may do this by editing Code Template.xml file in the following location:
C:\Users\username\AppData\Roaming\SQL Developer
Add/Edit the file to write convenient shortcut:
<row>
<key>upt</key>
<value>UPDATE table_name SET col_name='val' WHERE col_name='val';
</value>
</row>
[Please restart your sql developer after edit this file.]
So I have some formatting rule to follow, such as :
Space on each side of operator (*, =, +, %, etc)
No space at the end of a line
No more than 80 chars per line
Is there a way to highlight in red line containing formating error?
The eclipse auto-formating tool is no good because either :
It will change to many line (old code not written by me)
or it won't (only my code)
Because I must follow some "colorfull" guideline :
You must change formating error relative to operators in old code but nothing else
Your code must be correctly formated.
Any ideas?
Thanks
You can select which lines of code you want to format. The Eclipse formatting tool doesn't have to run across the entire file. To do this: select the lines you want to format, then press Ctrl-Shift-F.
You could try using the Eclipse Checkstyle Plugin.
You'll need to configure it with just the rules that you need (the default configuration is very strict, so create a new one with just the rules you care about).
This will highlight all lines with formatting issues. I don't think it's possible to ignore old code using the plugin.
Talk to whoever created that coding guideline. It does not make sense in the long run, because editing code in Eclipse will always apply all current formatting rules (which violates that guideline) or none, if you disable the formatter (which leads to you writing bad code).
If there is really no way around that guideline, then you should split your workflow into 2 phases: Reformat all existing code one time to fulfill that operator guideline. You may use any tool you like, even just a regular expression search and replace might be fine.
After that has been done, configure Eclipse to auto-format only changed lines, but always apply all formattings to each changed line. There is no good reason to not re-format the other 75 characters in an existing line of code, if you already touched 5 characters of it.