Presentation is loading. Please wait.

Presentation is loading. Please wait.

1.1 SQL Server 2005 管理工具介紹與使用. Overview Using SQL Server Management Studio Using SQL Configuration Manager Using the sqlcmd Utility.

Similar presentations


Presentation on theme: "1.1 SQL Server 2005 管理工具介紹與使用. Overview Using SQL Server Management Studio Using SQL Configuration Manager Using the sqlcmd Utility."— Presentation transcript:

1 1.1 SQL Server 2005 管理工具介紹與使用

2 Overview Using SQL Server Management Studio Using SQL Configuration Manager Using the sqlcmd Utility

3 Lesson: Using SQL Server Management Studio What Is SQL Server Management Studio? How to Register a Server What Is Object Explorer? How to Execute Transact-SQL Queries Demonstration: Using Transact-SQL in SQL Server Management Studio What Is a SQL Server Management Studio Solution? How to Create a SQL Server Management Studio Solution Demonstration: Creating a Solution with Solution Explorer

4 Lesson: Using SQL Configuration Manager What Is SQL Configuration Manager? Demonstration: Using SQL Configuration Manager How to Control Services How to View and Change Service Properties How to Manage Server Network Connectivity How to Manage Client Network Connectivity

5 Lesson: Using the sqlcmd Utility What Is the sqlcmd Utility? sqlcmd Command-Line Switches How to Use the sqlcmd Utility Interactively How to Execute Scripts Using the sqlcmd Utility How to Use Variables With the sqlcmd Utility Demonstration: Using Variables with the sqlcmd Utility How to Use a Dedicated Administrator Connection

6 What Is the sqlcmd Utility? Command-line tool for executing Transact-SQL statements and scripts  Uses OLE DB to run Transact-SQL batches  Replaces osql Enhancements over osql  Variables  Query server information  Passes error information to calling environment  Dedicated Administrator Connection  Commands

7 How to Use Variables with the sqlcmd Utility SELECT $(colname) FROM $(tabname) GO SELECT $(colname) FROM $(tabname) GO Sqlcmd 1>:Setvar DB adventureworksDW 2>:connect R20100 1>backup database $(DB) to disk=‘c:\backup\$(DB).bak’ 2>go Sqlcmd 1>:Setvar DB adventureworksDW 2>:connect R20100 1>backup database $(DB) to disk=‘c:\backup\$(DB).bak’ 2>go Set sqlcmddbname=adventureworks Sqlcmd 1>:ListVar 2>Quit Set sqlcmddbname=adventureworks Sqlcmd 1>:ListVar 2>Quit Set colname=name Set tabname=sys.databases Sqlcmd -i myscript.sql Set colname=name Set tabname=sys.databases Sqlcmd -i myscript.sql Sqlcmd 1>:ListVar 2>Quit Sqlcmd 1>:ListVar 2>Quit

8 How to Use Variables with the sqlcmd Utility Create a sqlcmd script referencing variables 1 1 Invoke sqlcmd with –v to define the variables, or use environment variables 2 2 sqlcmd –i MyScript.sql –o MyScript.out –v colname="name" tabname="sys.databases" SELECT $(colname) FROM $(tabname) GO SELECT $(colname) FROM $(tabname) GO

9 Demonstration: Using Variables with the sqlcmd Utility In this demonstration, you will see how to: Reference variables in a script Instantiate variables from the command line Use environment variables

10 How to Use a Dedicated Administrator Connection Useful if the server hangs or is unresponsive  DAC runs using its own private scheduler Connect using sqlcmd -A 1 1 Diagnose the problem, terminate misbehaving connections, or shut down cleanly 2 2 1> CHECKPOINT 2> GO 1> SHUTDOWN WITH NOWAIT 2> GO Server shut down by request 1> CHECKPOINT 2> GO 1> SHUTDOWN WITH NOWAIT 2> GO Server shut down by request


Download ppt "1.1 SQL Server 2005 管理工具介紹與使用. Overview Using SQL Server Management Studio Using SQL Configuration Manager Using the sqlcmd Utility."

Similar presentations


Ads by Google