Chapter 2: Database Administration and Development Tools


A lot has changed for the DBA in SQL Server 2005. There are several new subsystems that need to be managed, and in addition, the entire management tool set has been upgraded. Several of the administrative tools that were used to manage the previous versions of SQL Server have been replaced with new tools. In addition, a number of new management tools have been added as well. In this chapter, I’ll guide you through the new administrative features that Microsoft has added to the SQL Server 2005 release.

Management and Development Tools

SQL Server 2005 uses an entirely new set of management tools from any of the previous versions of SQL Server. In the next part of this chapter, you’ll get a closer look at the new management tools found in SQL Server 2005.

SQL Computer Manager

One of the first things that the experienced SQL Server DBA will notice about the new set of SQL Server 2005 management tools is that the Server Manager is missing. In the previous versions of SQL Server, the Server Manager was located in the System Tray. The Server Manager provided a graphic representation of the status of the different SQL Server Services, including the SQL Server service, the SQL Agent service, and the Distributed Transaction Coordinator service. You could also use the Server Manager to start and stop those services. While it was a handy tool, the Server Manager was not Windows Logo–compliant, and that was the main reason Microsoft removed it from SQL Server 2005. For SQL Server 2005, you can view and control the SQL Server services using the new SQL Computer Manager. The SQL Computer Manager is an MMC snap-in and can be accessed using the My Computer | Manage option. You can see the new SQL Computer Manager in Figure 2-1.

image from book
Figure 2-1: SQL Computer Manager

Using the SQL Computer Manager, you can see all of the SQL Server services that are running on the system listed underneath the main Services node. You use the Computer Management window to manage the following services: SQL Server, SQL Agent, ReportServer, MSSearch, MSDTC, Microsoft SQL Server Analysis Services, and Full Text.

You can control any service by first selecting it in the tree pane shown on the left side of the screen. This displays the status of the service in the details pane shown on the right side. To manage the service, you right-click the service in the details pane and then select the option to Start, Stop, Pause, Resume, or Restart the service from the pop-up context menu.

SQL Server Management Studio

The Server Manager isn’t the only familiar management tool that’s been changed in SQL Server 2005. The SQL Server Enterprise Manager, which was the primary management tool for SQL Server versions 7 and 2000, has been replaced by the new SQL Server Management Studio. Likewise, the Query Analyzer, which was the core T-SQL development tool in SQL Server versions 7 and 2000, has also been replaced by the new SQL Server Management Studio. SQL Server 2005 also provides a number of other administrative tools to the DBA, including the new Administrative Console, the Database Tuning Advisor, and a new Profiler.

The new SQL Server Management Studio is a radical departure from the administrative tools that were provided in the earlier releases of SQL Server. The new SQL Server Management Studio incorporates most of the functionality that used to be provided by SQL Server Enterprise Manager and Query Analyzer. The SQL Server Management Studio is accessed using the Start | Programs | Microsoft SQL Server | SQL Server Management Studio menu option. You can see the SQL Server Management Studio in Figure 2-2.

image from book
Figure 2-2: SQL Server Management Studio

The SQL Server Management Studio can be used to manage SQL Server 2005 systems as well as SQL Server 2000 and SQL Server 7 systems. It cannot be used on SQL Server 6.5 or older systems. You can use the older SQL Server 7 or SQL Server 2000 Enterprise Manager to manage a new SQL Server 2005 system, but because of some architectural changes between the two releases, this isn’t supported or recommended. And the older management tools cannot access any of the new features that have been added to SQL Server 2005. While you can perform basic database and table browsing, many other actions will result in errors. SQL Server Management Studio is the tool of choice for managing mixed SQL Server 2005 and SQL Server 2000 systems.

The SQL Server Management Studio is built using a specialized version of the Visual Studio 2005 IDE (interactive development environment). Like Visual Studio 2005, the SQL Server Management Studio supports the creation of software projects. It allows you to write, edit, run, and debug code. It is also integrated with Visual SourceSafe for source code version control. However, unlike Visual Studio 2005, it doesn’t allow you to compile VB.NET, C#, J#, or VC++. Instead, the SQL Server Management Studio works with T-SQL, MDX, MX, and XMLA.

The SQL Server Management Studio offers a number of important improvements over the SQL Server Enterprise Manager and the Query Analyzer combination. First, all of the dialog boxes displayed by the SQL Server Management Studio are non-modal, which means that you don’t have to respond to the dialog before you can do anything else. The dialog boxes that were used by the old SQL Server Enterprise were all modal, and if you opened a dialog, you couldn’t do anything else until the dialog was closed. The new non-modal dialogs used by the SQL Server Management Studio solve that problem and make it possible for the DBA to perform other management tasks while one of the dialogs is displayed.

In addition, the SQL Server Management Studio deals with large numbers of database objects much better than the old SQL Server Enterprise Manager. In the previous versions of SQL Server, the SQL Server Enterprise Manager always enumerated all of the database objects when it connected to a registered server. For most small and medium-sized businesses, this wasn’t a problem. However, for organizations with very large databases containing thousands of database objects, the SQL Server Enterprise Manager could take a very long time listing all of the database objects and their properties—essentially rendering the SQL Server Enterprise Manager unusable until all of the objects were listed. With SQL Server 2005, the SQL Server Management Studio is much smarter in the way it handles database objects in that it doesn’t enumerate the database objects until the user chooses to expand a database item display in the Object Browser. This enables the SQL Server Management Studio to provide much better responsiveness when it’s used to manage very large databases.

The SQL Server Management Studio serves as the host for the majority of the SQL Server management and development tools. The Registered Servers window allows you to select the SQL Server systems that you will manage. The Object Explorer window enables you to work with the database objects in each server. And the Solutions Explorer window enables you to group your database source code into logical collections. You can find out more about the Registered Servers, Object Explorer, Query Editor, and Solution Explorer in the following sections in this chapter. More information about the Report Designer is presented in Chapter 8. The DTS Designer is covered in Chapter 9.

Registered Servers

Very much as when using the SQL Server Enterprise Manager, you must register servers in the SQL Server Management Studio before you can use it to manage them. You use the SQL Server Management Studio’s Registered Servers window (shown in the upper left-hand portion of Figure 2-2) to register new SQL Server systems. Also as in the SQL Server Enterprise Manager, the SQL Server Management Studio’s Registered Servers window enables you to group common servers together into logical server groups. To register a new SQL Server system in the Registered Servers window, you right-click in the window and select the New | Server Registration option from the context menu. Similarly, to create a new server group, you right-click in the Registered Servers window and select the New | Server Group option from the context menu. One nice feature in the Registered Servers window is the ability to export and import all of the registered servers. This enables you to quickly populate the Registered Servers windows of other SQL Server Management Studios without having to manually reregister all of the managed servers.

After a server is registered, you can manage its services by right-clicking the server in the Registered Servers window. This displays a context menu that enables you to connect to the server as well as start, stop, pause, resume, or restart the SQL Server service. You can work with a server’s database objects by double-clicking the server name. This will connect you to the registered SQL server and will automatically open the Object Explorer window.

Object Explorer

The SQL Server Management Studio Object Explorer window enables you to perform the same management functions that were possible using the SQL Server Enterprise Manager. You can see the Object Explorer window in the lower left-hand corner of Figure 2-2. Using the Object Explorer, you can

  • Start and stop a server

  • Configure a server’s properties

  • Create databases

  • Attach or detach databases

  • Create database objects such as tables, views, or stored procedures

  • Generate T-SQL object creation scripts

  • Set up server logins

  • Manage database object permissions

  • Configure and manage replication

  • Configure and manage linked servers

  • Monitor server activity

  • View system logs

To work with the database objects displayed in the Object Explorer, you right-click the desired object in the Object Explorer tree to display the object’s context menu. The context menu provides a unique set of options for each of the different database objects. For instance, the database context menu allows you to delete, rename, attach, detach, shrink, back up, and restore databases, while the table context menu allows you to create a new table, modify a table, open the table view dependencies, and set permissions.

Another cool feature of the new Object Explorer is its ability to easily generate scripts to create any of the database objects shown in the Object Explorer list. The Script Wizard can be used to document a database’s schema, to create a backup of a database, or to create a test copy of a database or selected database objects. You can choose to create a single script for all of the selected objects or to create multiple scripts—one for each object. The T-SQL scripts can be output to a file, to the clipboard, or to the SQL Server Management Studio Query Editor.

Query Editor

The Query Editor is the replacement for Query Analyzer. It enables you to write and run T-SQL scripts. You can see the Query Editor in the upper-middle portion of Figure 2-2. You start the Query Editor from the SQL Server Management Studio by either selecting the New Query option on the Start page or selecting the File | New | SQL Server Query | SQL Server Query option. The Query Editor supports developing queries in T-SQL, MDX, DMX, XMLA, and SQL Mobile Queries. Unlike the Query Analyzer, which always worked in connected mode, the new Query Editor has the option of working either connected or disconnected from the server. By default, it automatically connects to the server as soon as you opt to create a new query.

Like its Visual Studio 2005 counterpart, the Query Editor supports color-coded keywords, visually shows syntax errors, and enables the developer to both run and debug code. In addition, unlike the old Query Analyzer, the Query Editor supports the concept of projects, where groups of related files can be grouped together to form a solution. The new Query Editor also offers full support for source control using Visual SourceSafe. The Query Editor also adds in the elements that were present in Query Analyzer. It is able to display query results in a grid or as text, and it is able to graphically show a query’s execution plans. There’s also an option to save your T-SQL scripts using the built-in SourceSafe version control. Version control facilitates group development by preventing multiple developers from simultaneously changing the same module. Source code must be checked out of the code repository before it can be modified and then checked back in, giving you a central location to store your database code. Using version control with your T-SQL database creation scripts provides a valuable method for isolating the source code associated with each release of your database schema. This can also act as a basis for comparing the schema of a deployed database to the expected schema that’s been saved using version control. Plus, as you’ll see in “Performance Tools” later in this chapter, Query Editor also has the capability to graphically represent a query’s execution plan.

Results Window

The SQL Server Management Studio’s Results window displays the results of the queries that were executed in the Query Editor. You can see the Results window in the lower-right section of Figure 2-2. The Results window can be set up to display query results either in text format or in a grid.

Solution Explorer

Another important management tool that’s provided as part of the SQL Server Management Studio is the Solution Explorer. You can see the Solution Explorer in the upper right-hand corner of Figure 2-3. The Solution Explorer is used to provide a hierarchical tree view of the different projects and files in a solution. The top item listed in the Solution Explorer is the name of the SQL Server Management Studio solution. By default, this name is Solution 1, but you can change this to whatever name you want by selecting the solution and then changing its name in the Properties window.

image from book
Figure 2-3: SQL Server Management Studio—Solution Explorer

Under the solution, you can have one or more project items or one or more files. The files that are listed in the Solution Explorer can be associated with a project, or else they can be associated with the SQL Server Management Studio solution itself without an intermediate project. The files can include all of the different file types that can be modified using the SQL Server Management Studio, including T-SQL Queries, Analysis Server Queries, and XMLA Queries.

The SQL Server Management Studio Solution Explorer supports a number of different project types, including SQL Server Scripts, Analysis Server Scripts, and SQL Mobile Scripts. You can see the SQL Server Management Studio’s New Project dialog in Figure 2-4.

image from book
Figure 2-4: SQL Server Management Studio—New Project

SQL Server Scripts

The SQL Server Scripts projects are used to group together related SQL Server connections and T-SQL scripts. One common use for this type of project is to group together all of your database’s Data Definition Language (DDL) scripts.

Analysis Server Scripts

Much as SQL Server Scripts are used for T-SQL-based files, Analysis Server Scripts projects are intended to contain Analysis Server connections as well as MDX and XMLA scripts. Again, one way you might take advantage of this type of project is to have the project contain all of the scripts that create your data warehouse and another project might contain the scripts to load your data warehouse.

SQL Mobile Scripts

SQL Mobile Scripts projects are used to group together the connections and queries for a SQL Server CE database. For a SQL Server CE project, a connection object represents the connection to the CE database.

Properties

The Properties window shown in the lower right-hand corner of Figure 2-3 is used at design time to set the properties of the objects selected in the Solution Explorer. You can use the Properties window for a number of different tasks, including setting the names of your solutions, projects, and files, as well as controlling the time-out for DTS packages. One nice feature about the Properties window that’s not immediately obvious is the fact that you can use it to simultaneously set the properties for multiple items. To do this, you select multiple items in the Solution Explorer window by holding down the CTRL key and then clicking the items. Then when you change a value in the Properties window, it will be changed for all of the selected items. As you might expect, the selected items in the Solution Explorer window must share common properties for this to work.

Dynamic Help

Like the Visual Studio 2005 IDE that it’s based on, the SQL Server Management Studio also provides a new Dynamic Help window. The contents of the Dynamic Help window automatically change according to the position of the current cursor or mouse pointer in the SQL Server Management Studio.

Source Control

Integrated source control is another new feature that’s provided by the SQL Server Management Studio. Source control facilitates team development by providing a central control mechanism that manages access to source files. In order to use the SQL Server Management Studio source control feature, you must have previously installed Visual SourceSafe, which comes with Microsoft’s Visual Studio 2005 product. The SQL Server Management Studio source control feature provides a check-in and check-out process to ensure that two developers cannot simultaneously change the same source file (and potentially wipe out one another’s modifications). The source control system is also able to archive past versions of each project. You can add solutions projects and files to the Visual SourceSafe source control system by using the File | Source Control option from the SQL Server Management Studio menu.

Current Activity Window

As if it didn’t encompass enough functionality already, SQL Server 2005’s new SQL Server Management Studio also provides an integrated process monitoring feature called the Current Activity window. You can run the Current Activity Monitor from the Object Explorer by selecting the Database | Management | Activity Monitor node. The Current Activity window gives you an overview of the current processes running on your SQL Server system. It shows

  • Process information

  • Blocked processes

  • User connections

  • Locks

  • User locks

Business Intelligence Development Studio

Just as the SQL Server Management Studio is used to develop relational database projects, the new Business Intelligence Development Studio is used to create Business Intelligence solutions. Unlike the SQL Server Management Studio, the Business Intelligence Development Studio is not really designed to be an administrative tool. You use the Business Intelligence Development Studio to work with Analysis Services projects, to develop and deploy Reporting Services reports, and to design Data Transformation Services packages.

Since the Business Intelligence Development Studio has a different purpose from the SQL Server Management Studio, it also has a different look and feel. In addition, while the SQL Server Management Studio utilized a connected mode by default, the Business Intelligence Development Studio starts off in a disconnected mode. The Business Intelligence Development Studio is accessed using the Start | Programs | Microsoft SQL Server | Business Intelligence Development Studio menu option. You can see a picture of the Business Intelligence Development Studio in Figure 2-5.

image from book
Figure 2-5: Business Intelligence Development Studio

Like the SQL Server Management Studio, the Business Intelligence Development Studio is built on top of the Visual Studio 2005 IDE. It provides a solution-oriented development environment where one or more projects are contained in a solution. Each project consists of the types of objects that are suitable for that project. For example, a Reporting Services project will contain Report definitions, while a DTS project contains DTS package objects. Like the SQL Server Management Studio, the Business Intelligence Development Studio doesn’t allow you to compile VB.NET, C#, J#, or VC++. Instead, the Business Intelligence Development Studio is designed expressly for working with BI projects like DTS and Reporting Services. The Business Intelligence Development Studio is also integrated with Visual SourceSafe for source code version control.

Toolbox

The Toolbox window in the Business Intelligence Development Studio is shown on the left side of the screen in Figure 2-5. The Toolbox is used by the DTS Designer and the Reporting Services Designer to drag and drop components onto their respective design surfaces.

Solution Explorer

Like the SQL Server Development Studio, the Business Intelligence Development Studio also has a Solution Explorer window. You can see the Solution Explorer at the upper right-hand corner of the screen shown in Figure 2-5. The Solution Explorer provides a hierarchical tree view of the different projects and files that compose a Business Intelligence Development Studio solution. The top item in the Solution Explorer hierarchy is the solution name. Under the solution, you can have one or more project items and/or multiple items. The Business Intelligence Development Studio Solution Explorer provides the following project templates: Analysis Services Project, Data Transformation Project, Import Analysis Services 9.0 Database, Report Project, and Report Project Wizard. As in the SQL Server Management Studio, Business Intelligence Development Studio solutions are not restricted to one project. You can create multi-project solutions that are made up of any of the supported project types. You can see the Business Intelligence Development Studio’s New Project dialog in Figure 2-6.

image from book
Figure 2-6: Business Intelligence Development Studio—New Project

Analysis Services Project

Analysis Services projects contain the definitions for the objects in an Analysis Services database. These include the definitions for data sources, data source views, cubes, dimensions, mining models, roles, and assemblies. One of the primary tools in the Analysis Services projects is the Cube Designer.

The Cube Designer is a visual tool for building OLAP cubes. It is started by double-clicking the Cube node shown under an Analysis Services project or by right-clicking the Cube node and selecting View Designer. More detailed information about the cube designer is presented in Chapter 10.

Data Transformation Project

The project definition for Data Transformation projects enables you to create the objects used in a DTS solution. These definitions include the creation of data sources, data source views, and DTS packages.

The DTS Designer, shown in the middle of the screen in Figure 2-5, enables you to visually create DTS packages by selecting the DTS components from the toolbar and dragging and dropping them onto the DTS design surface. Using the DTS Designer, you can specify the data sources, select the types of transformations that will be used, as well as set up the DTS package’s data flow. You can find out more about DTS in Chapter 9.

Import Analysis Services 9.0 Database

The Import Analysis Service 9.0 project type enables you to create a new SQL Server 2005 Analysis Services project by importing the definitions for an existing SQL Server 2000 Analysis Services or SQL Server 7 OLAP Server database.

Report Project

You use the Report Project template to create Reporting Services projects. This project template starts the Reporting Services Designer, where you select data sources and visually lay out reports.

The Reporting Services Designer enables you to visually design reports as well as control their deployment. Using the Reporting Services Designer, you create a Dataset and then use the visual design surface along with controls from the Report Items toolbox to lay out reports. These reports can run against a SQL Server 2005 database as well as any OLE DB- and ODBC-compliant database sources. Reporting Services and the Report Designer are covered in more detail in Chapter 8.

Report Project Wizard

The Report Project Wizard project template starts the Report Wizard, which guides you through a series of easy-to-use screens that enable you to define a basic report. The integrated Query Builder is included in the Report Wizard to help you construct your SQL queries. Once you’ve created a report using the Report Wizard, you can go back and fine-tune it using the Report Designer. The Report Wizard is also covered in more detail in Chapter 8.

Properties

The Properties window shown in the bottom-right corner of Figure 2-5 is used at design time to set the properties of the objects selected in the Solution Explorer.

Dynamic Help

Like the SQL Server Management Studio, the Business Intelligence Development Studio also has a new Dynamic Help window. The help contents shown in the Dynamic Help window change according to the position of the current cursor or mouse pointer in the Business Intelligence Development Studio.

Source Control

The Business Intelligence Development Studio also provides completely integrated source control using Visual SourceSafe. Source control facilitates team development by providing a central control mechanism that manages access to source files. To use the source control feature with the Business Intelligence Development Studio, you need to have previously installed Visual SourceSafe, which is distributed with Visual Studio 2005. Source control provides a check-in and check-out process to ensure that two developers cannot simultaneously change the same source file, and it is also able to archive past versions of each project. You can add solutions, projects, and files to the source control system by using the File | Source Control option from the Business Intelligence Development Studio.

When to Use the SQL Server Management Studio and the Business Intelligence Development Studio

While they may seem similar at first, the SQL Server Management Studio and Business Intelligence Development Studio are designed to fulfill different purposes. Both the SQL Server Management Studio and the Business Intelligence Development Studio are based on the Visual Studio 2005 IDE, and since SQL Server 2005 ships with both a SQL Server relational database server and an Analysis Services OLAP server, you might be tempted to think that the SQL Server Management Studio is used to manage SQL Server while the Business Intelligence Development Studio is used to manage Analysis Services. That’s not the case. The SQL Server Management Studio is used to manage both SQL Server and Analysis Services as well as to develop T-SQL and MDX queries. The SQL Server Management Studio can connect to instances of SQL Server, Analysis Services, and Reporting Services. You can use it to start and stop those services, as well as to manage them using the SQL Server Management Studio GUI or by running scripts.

The Business Intelligence Development Studio is not an administrative tool. Instead, the Business Intelligence Development Studio is designed to enable you to develop and deploy business intelligence solutions. It can be used to design DTS packages and Reporting Services reports as well as create and run MXD and XMLA queries, but it’s not used to manage Analysis Services.

Sqlcmd

Another important new management tool found in SQL Server 2005 is the new Sqlcmd utility. The Sqlcmd utility is essentially a replacement for the older osql and isql utilities found in the earlier releases of SQL Server. The old isql program used the deprecated SQL Server DB-library to connect to SQL Server, while the osql program uses ODBC. The new Sqlcmd utility connects to SQL Server using OLE DB. For backward compatibility, the osql utility is still shipped with SQL Server 2005. However, isql has been dropped from the SQL Server 2005 release. Like those tools, the Sqlcmd utility is run from the command prompt and enables you to enter and execute T-SQL statements, stored procedures, and T-SQL batches.

One important feature that the Sqlcmd utility has in addition to the ability to execute commands is the fact that it can connect to the database with a Dedicated Administrative Connection (DAC). The DAC permits you to connect and run at a higher priority than any other SQL Server process, enabling you to terminate any runaway process. To use the DAC, you must start the Sqlcmd utility using the –A switch. You can find more information about Sqlcmd’s DAC capability in Chapter 4. In addition to the –A switch, the Sqlcmd utility supports a number of other useful command-line switches. For example, you can use the –L switch to list all of the registered SQL Server systems, as shown here:

Sqlcmd –L

Another useful switch is the –p switch, which outputs the performance statistics for the result set. You can get a full listing of the supported command-line switches by entering Sqlcmd /? at the command prompt.

Sqlcmd Scripting

In addition to supporting the execution of standard T-SQL statements, the Sqlcmd utility also supports a number of scripting extensions that enable you to include flow control and variables in your scripts. You can define scripting variables implicitly using the –v switch, or you can set them using the command-shell setvar command. The following example illustrates how you can combine the Sqlcmd command-line switches with variables used in scripts:

sqlcmd -S MySQLServer –d AdventureWorks -v CUSTOMER -i MyScript.sql

Note 

The Sqlcmd utility uses a trusted connection by default.

This example uses the –S switch to specify the SQL Server system name. The –d switch specifies the database that it will be connected to. The –v switch is used to define a variable named VENDORNAME and supply that variable with the value of International. The –I switch is used to tell the Sqlcmd utility that the T-SQL command will come out of the file MyScript.sql. You can see the contents of the MyScript.sql file in this listing:

select * from Purchasing.Vendor where Name = '$(VENDORNAME)'

In addition to providing for user-defined variables, Microsoft has also provided a set of predefined variables that can be used with Sqlcmd scripts. Table 2-1 lists the extended variables that Microsoft has added to the Sqlcmd utility and the command-line switches that can be used to supply values for those variables.

Table 2-1: Sqlcmd Extended Variables

Variable

Command–Line Switch

SQLCMDUSER

–U

SQLCMDPASSWORD

–P

SQLCMDSERVER

–S

SQLCMDWORKSTATION

–H

SQLCMDDBNAME

–d

SQLCMDLOGINTIMEOUT

–l

SQLCMDSTATTIMEOUT

–t

SQLCMDHEADERS

–h

SQLCMDCOLSEP

–s

SQLCMDCOLWIDTH

–w

SQLCMDPACKETSIZE

–a

SQLCMDERRORLEVEL

–m

In addition to providing a set of predefined variables, the Sqlcmd utility also provides a list of extended commands. The extended Sqlcmd utilities commands are listed in Table 2-2.

Table 2-2: Sqlcmd Extended Utilities
CommandDescription

[:]GO [count]

Signals the end of a batch and executes the cached statements. Adding an optional count value executes the statements a given number of times.

[:]RESET

Clears the statement cache.

[:]ED

Starts the next edit for the current statement cache.

[:]!!

Executes operating system commands.

[:]QUIT

Ends the Sqlcmd utility.

[:]EXIT (results)

Uses the value of a result set as a return value.

[:]r <filename>

Includes additional Sqlcmd statements from the specified file.

:ServerList

Lists the configured SQL Server systems.

:List

Lists the contents of the statement cache.

:Error <filename>

Redirects error output to the specified file.

:Out

Redirects query results to the specified file.

:Perftrace <filename>

Redirects performance statistics to the specified file.

:Connect [timeout]

Connects to a SQL Server instance.

:On Error [exit |retry | ignore]

Specifies the action to be performed when an error is encountered.

:XML [ON | OFF]

Specifies whether XML results will be output as a continuous stream.

The following listing gives you an idea of how the Sqlcmd utilities’ extended commands can be used. This example connects to the server and then uses the :EXIT command to return the row count from the customers table:

C:\>sqlcmd  1> use adventureworks  2> :EXIT(select count(*) from sales.customer) Changed database context to 'AdventureWorks'. -----------          91 (1 rows affected)




Microsoft SQL Server 2005 New Features
Microsoft SQL Server 2005 New Features
ISBN: 0072227761
EAN: 2147483647
Year: 2005
Pages: 80
Authors: Michael Otey

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net