Home

Transact-SQL and Data Selection

 

Introduction

Data Analysis is actually performed using SQL code that contains one or more criteria. To prepare for data analysis, you have various options:

  • If you haven't yet decided what table holds the data you want to analyze, in the Object Explorer (Microsoft SQL Server Management) or Server Explorer (Microsoft Visual Studio), you can right-click a table and click New Query. Then, in the query window, enter the necessary SQL statement
  • If you know the table that holds the data you want to analyze, in the Object Explorer of the Microsoft SQL Server Management, right-click the table, position the mouse on Script Table As, followed by SELECT To, and click New Query Editor Window. A query window would be opened with sample SQL code
 
  

Showing the Results of SQL Data Selection

After entering the SQL statement, you can execute it to see the result. In Microsoft SQL Server Management Studio, this would display the Table window. The result would be displayed in the bottom section. There are two ways you can display the result. To have access to these options, you can first display the SQL Editor toolbar. In Microsoft SQL Server Management Studio, to display the SQL Editor toolbar:

  • On the main menu, you can click View -> Toolbars -> SQL Editor
  • You can right-click any toolbar and click SQL Editor

In Microsoft SQL Server Management Studio, to specify how you want to show the results of your SQL statement, you have two options:

  • To show the result as text, on the SQL Editor toolbar, you can click the Result To Text button Result Text. Alternatively, you can right-click somewhere in the table, position the mouse on Results To, and click Results To Text.

    The results would appear in two columns of text. Here is an example:

Result To Text

 

  • To show the result as a spreadsheet, on the SQL Editor toolbar, you can click the Result To Grid button Result to Grid. Alternatively, you can right-click somewhere in the table, position the mouse on Results To, and click Results To Grid.

    The results would appear as a spreadsheet of one or various columns. Here is an example:

Result To Grid

In either the Table window or the query window, you are expected to write appropriate code that would constitute a SQL statement.

Published on Friday 04 January 2008


Previous Copyright © 2007 FunctionX, Inc. Next