Automatically generate a SELECT statement in SSMS

Overview

From your previous examples, I want to find out how to get SQL Server Management Studio (SSMS) to do the work for me.  How can I have this tool generate a SELECT statement rather than typing out each of the columns?

Explanation

SQL Server Management Studio does have a simple means to automatically generate a SELECT statement from a single table.  Let’s follow the steps below:

Once you are in SQL Server Management Studio, right click on the table you which you would like to have the SELECT statement generated for.

toGenerateSelectStatement 1

On the subsequent interface, select the ‘Script Table as’ option.

toGenerateSelectStatement 2

On the subsequent interface, select the ‘SELECT To’ option.

toGenerateSelectStatement 3

On the subsequent interface, select the ‘New Query Editor Window’ option.

toGenerateSelectStatement 4

Below is a sample image of the SELECT code generated for a table.

toGenerateSelectStatement 5

Leave a Reply

Your email address will not be published. Required fields are marked *