Search This Blog

SQL Server useful tips, tricks and shortcuts

SQL Server useful tips, tricks and shortcuts

For Below Headings we will display you some SQL Server useful tips,tricks and Shortcuts.

1. Display Line Numbers in SQL Editor
2. Comment SQL Code Shortcut
3. Uncomment SQL Code
4. SQL Code into Upper Case
5. SQL code into Lower Case
6. Add/View/Delete Bookmark in SQL


Display Line Numbers in SQL Editor


While working with large SQL Code it’s better to display line Numbers so that if in case you will get any error you can find the exact line Number.


1.       Open SSMS
2.       Click Tools-Options
3.       Expand Text Editor
4.       Click on Transact-SQL
5.       Check Box-Line Numbers
6.       Ok –As in Below Screenshots.


Comment SQL Code Shortcut

There are two ways to comment your SQL code.
  1.       Using  tool bar
  2.     Select your code
  3.     Click on icon as in screenshot.


2nd Method to comment SQLcode    
  1.       Select your code
  2.       Press CTRL+K,CTRL+C
         This will comment your entire Selected Code.


Uncomment SQL Code Shortcut


There are two ways to uncomment your SQL code.
  1.   Using  tool bar
  2.   Select your code
  3. Click on icon as in screenshot.

2nd Method to Uncomment SQL code
  1.    Select your code
  2.      Press CTRL+K,CTRL+U
      This will comment your entire Selected Code.

SQL Code into Upper Case


In order to follow proper SQL coding Standards, sometimes you need to change your code into Upper case.
  1.   Select your SQL code that you want to change into Upper Case
  2.    Press CTRL+SHIFT+U
   All Selected Code will get Converted into Upper case

SQL Code into Lower Case


 In order to follow proper SQL coding Standards, sometimes you need to change your code into Lower case.
  1.       Select your SQL code that you want to change into Lower Case
  2.       Press CTRL+SHIFT+L
        All Selected Code will get Converted into Lower Case

 

Add/View/Delete Bookmark


Sometimes while working with SQL Code you want to bookmark a Specific text .Wherever you will have that specific text in the code it will add a bookmark to that line as below screenshot.

Add Bookmark


  1.       Press CTRL+F
  2.      Click –Bookmark ALL

To view Bookmark Window


  1.        Press CTRL+K, CTRL+W
  2.     2nd way Go to View Menu-Click on Bookmark Window.

To Delete Bookmark Window


  1.        Press CTRL+K, CTRL+L
  2.      From Bookmark window delete all bookmarks as below.