Pages

Social Icons

Tuesday 28 April 2015

Simple tricks in SQL-Server

Here I am going to explain some cool tricks in SQL-Server.

Trick 1: Code Wrap

Some times will see our code is going to beyond the window size and will get the scroll bar at the bottom and every time we need to scroll to see the full code. We can remove this scroll bar just setting the word-wrap property in SQL- Server.

For this go into the tools -> Options

In the pop up window select text -> General. In this click on the word wrap check box and hit the ok button.


Trick 2: Create Table from another table with out data

If we want to create a table from another table but with out data. Then we can use the below query.

 SELECT * INTO ChatMessage FROM Chat WHERE id = 0

Trick 3: Short cut to select all rows from the table

For selecting all the rows from the table every time we are writing a query as below

SELECT FROM ChatMessage

In SQL-Server we can assign the shortcut key for this as below.


  • Go to Tools -> Options
  • In the pop up window select Keyboard -> Query Shortcut
  • Now select any blank shortcut key and write "SELECT FROM ". Make sure you will have a blank space after from.


Now go to the query window and write only the table name. Select the table and press the shortcut key which you have assigned.

Thanks,
RS




1 comment:

  1. What you're saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I'm sure you'll reach so many people with what you've got to say.

    ReplyDelete