Script Multiple Objects [Easy]

Facebooktwitterredditpinterestlinkedinmail

Have you ever noticed that you can only highlight 1 object in the Object Explorer in SQL Server Management Studio? This usually is enough for most things you do, but if you want to script multiple objects at once… it becomes a pain. Well there is a way to script multiple objects at once, and it’s super easy.

  1. Open the Object Explorer Details screen by selecting View -> Object Explorer Details.
    Script Multiple Objects 1
  2. Highlight the folder with the objects that you would like script. A list of all objects in that folder will appear on the right. This works for tables, stored procedures, etc…
    Script Multiple Objects 2
  3. Highlight all the objects that you want, right click, and select Create To.
    Script Multiple Objects 3

Adding All Columns In A Table To A Query [Easy]

Facebooktwitterredditpinterestlinkedinmail

I wanted to share this quick tip with you on how to add a list of all the columns in a table to your query window in SQL Server Management Studio. This is the easiest way I know!

  1. Expand the Object Explorer to show the table that you want to add the columns for.
        Adding All Columns 1
  2. Select the Columns folder on to your query window.
        Adding All Columns 2
  3. Drag the whole folder on to your query window and just drop it where you want it. That’s it!
    Adding All Columns 3

5 Quick Tips For Using SQL Server Management Studio

Facebooktwitterredditpinterestlinkedinmail

1) Script multiple objects by using the Object Explorer Details.

Scripting objects like tables and stored procedures is one great feature of SQL Server Management Studio.  But the way to script multiple tables at one time is not very straight forward.

To script multiple objects, first thing you need to do is open the Object Explorer Details window.  This is located under the VIEW menu at the top of the screen.

Object Explorer Details

When you click on an object’s folder (Tables, Stored Procedures, Views, etc) in the Object Explorer (located on the left of the screen), the Object Explorer Details window will show all of the available tables.  You can now highlight multiple objects… then right click and select the Script As option.

SQL Server Object Explorer-details-window-script

 
 
2) Add Line Numbers To The Query Window

Line numbers can be very useful when doing development.  By default, SQL Server Management Studio has this turned off.  To turn this on:

  1. Select Tools -> Options
  2. In the tree on the left, select Text Editor -> All Languages. Under the Display heading, check the box for Line numbers.

Enable Line Numbering

 
 
3) How To Refresh The IntelliSense Cache

If you’ve ever added a table or stored procedure, you know that the IntelliSense does not know about it.  You can refresh the cache pretty easily.  To refresh the IntelliSense cache, just selecting Edit -> IntelliSense -> Refresh Local Cache.

SQL Server IntelliSense Refresh Cache

 
 
4) Highlight Columns Of Text In Query Window

This trick actually works in Visual Studio also.  You can highlight and manipulate text in different rows without having to highlight the entire row.  This is a little hard to explain, so I will show you pictures of what I mean.

Query Highlight Columns

To do this fancy trick, all you need to do is hold down the ALT key while you click and drag.

So, how is this useful you ask… good question.  I use it for 2 different things.

  • First is for aligning the sql statement. If you highlight text you can just hit tab and it will tab the highlighted text in more.
  • The second thing I use it for is copying data. If you only want to pull out a specific set of data, this is super easy.

 
 
5) Drag And Drop Objects On To Query Window

If you ever want a fast way to place a table name, column name, or other object in to a query… you can just drag and drop.  Just drag the object (table, column, store procedure, etc…) from the object browser and place it where you want it on the query window.  It will insert the fully qualified name in to the query with no typing needed.

Drag-Drop Objects