Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module 3: SQL Server 2005 Administrative Tools. Overview Using SQL Server Management Studio Using SQL Computer Manager Using the sqlcmd Utility Using.

Similar presentations


Presentation on theme: "Module 3: SQL Server 2005 Administrative Tools. Overview Using SQL Server Management Studio Using SQL Computer Manager Using the sqlcmd Utility Using."— Presentation transcript:

1 Module 3: SQL Server 2005 Administrative Tools

2 Overview Using SQL Server Management Studio Using SQL Computer Manager Using the sqlcmd Utility Using the SQL Management Objects

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 Integrated management and development environment Based on Visual Studio.NET Incorporates functionality of Enterprise Manager, Query Analyzer, and Analysis Manager in previous releases Used to manage relational databases, Analysis Services, Reporting Services, SQL Server Integration Services, and SQL Mobile databases Includes tools for creating Transact-SQL, XMLA, MDX, and XQuery scripts What Is SQL Server Management Studio?

5 How to Register a Server Open Registered Servers window 1 1 Test the registered server 3 3 Verify that the server appears under Registered Servers 4 4 Provide SQL Server instance details 2 2

6 What Is Object Explorer? Window for browsing and managing objects Object Explorer folders Object Explorer buttons

7 How to Execute Transact-SQL Queries Click New SQL Server Query 1 1 Click Execute and connect to SQL Server 3 3 Browse the results 4 4 Type a Transact-SQL statement 2 2

8 Demonstration: Using Transact-SQL in SQL Server Management Studio In this demonstration, you will see how to create and execute a query

9 What Is a SQL Server Management Studio Solution? Collection of connections and queries Project templates

10 How to Create a SQL Server Management Studio Solution Set the query properties 6 6 Type the Transact-SQL statements 7 7 Create a new query 5 5 Save the project 8 8 Click File, New, Project 1 1 Select the SQL Server Scripts template 2 2 Add a connection 3 3 Set the connection properties 4 4

11 Demonstration: Creating a Solution with Solution Explorer In this demonstration, you will see how to create a SQL Server Management Studio solution

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

13 What Is SQL Computer Manager? Console snap-in for managing SQL Server services and connectivity Icons:  Services  Server Network Configuration  Client Network Configuration

14 Demonstration: Using SQL Computer Manager In this demonstration, you will see how to: Start SQL Computer Manager View SQL Server 2005 Services View Server Network Configuration View Client Network Configuration

15 Start, stop, pause, resume, or restart a service How to Control Services Open the SQL Computer Manager 1 1 Click a service and select a service instance 3 3 Click the action 4 4 Expand Services 2 2

16 How to View and Change Service Properties Click a service and select a service instance 1 1 Click Action, Properties 2 2 Click the Service or Advanced tab 3 3 Update the property and click OK 4 4

17 How to Manage Server Network Connectivity Enable or disable a server protocol View the Server Network Configuration node 1 1 Select an instance and a protocol 2 2 Click Action, Enable or Action, Disable 3 3 Change address parameters of a server protocol Select an instance and a protocol 1 1 Click Action, Properties 2 2 Modify settings and click OK 3 3

18 How to Manage Client Network Connectivity Enable or disable a client protocol View the Client Network Configuration node 1 1 Click Client Protocols and select a protocol 2 2 Click Action, Enable or Action, Disable 3 3 Change parameters of a client protocol Click Client Protocols and select a protocol 1 1 Click Action, Properties 2 2 Modify settings and click OK 3 3

19 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

20 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

21 sqlcmd Command-Line Switches sqlcmd [-?] | [-L[c]] | [ { {-U login_id [-P password]} | –E } [-S server_name[\instance_name]] [-H wksta_name] [-d db_name] [-l time_out] [-t time_out] [-h headers] [-s col_separator] [-w column_width] [-a packet_size] [-e] [-I] [-c cmd_end] [-q "query"] [-Q "query"] [-m error_level] [-r [0 | 1]] [-i input_file[,file2…]] [-o output_file] [-p[1]] [-b] [-u] [-R] [-v var="value"[var="value"…]][-A] [-X[1]] [-V severitylevel] ] sqlcmd [-?] | [-L[c]] | [ { {-U login_id [-P password]} | –E } [-S server_name[\instance_name]] [-H wksta_name] [-d db_name] [-l time_out] [-t time_out] [-h headers] [-s col_separator] [-w column_width] [-a packet_size] [-e] [-I] [-c cmd_end] [-q "query"] [-Q "query"] [-m error_level] [-r [0 | 1]] [-i input_file[,file2…]] [-o output_file] [-p[1]] [-b] [-u] [-R] [-v var="value"[var="value"…]][-A] [-X[1]] [-V severitylevel] ]

22 How to Use the sqlcmd Utility Interactively Open a command prompt window 1 1 Execute sqlcmd 2 2 Type Transact-SQL statements and sqlcmd commands 3 3 Type GO 4 4 Type QUIT to close sqlcmd 5 5

23 Create a file containing Transact-SQL statements and sqlcmd commands 1 1 Set the connection environment variables 2 2 Invoke sqlcmd specifying –i and –o switches 3 3 Examine ERRORLEVEL 4 4 Examine the output file 5 5 How to Execute Scripts Using the sqlcmd Utility

24 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

25 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

26 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

27 Lesson: Using the SQL Management Objects What Are the SQL Management Objects? SMO Compared to SQL Server Distributed Management Objects How to Create SMO Applications How to Use SMO to Retrieve Server Information How to Use SMO to Back Up a Database Demonstration: Using SMO

28 What Are the SQL Management Objects? JobServer Jobs Job Alerts Shared Schedules Job Schedule Server ConnectionContext Databases Database Assemblies SqlAssembly FileGroups FileGroup Tables Table

29 SMO Compared with SQL Server Distributed Management Objects SMO is a replacement for SQL-DMO SQL-DMO retained only for backward compatibility SMO uses an administrator-centric view SMO and WMI  For monitoring and configuring servers SMO Scripting  Scripter class provides enhanced scripting features

30 How to Create SMO Applications Connect to the computer running SQL Server 5 5 Open Visual Studio 2005 1 1 Create a new project 2 2 Reference the SQL SMO assemblies 3 3 Import the SMO namespaces 4 4 Code your application 6 6

31 How to Use SMO to Retrieve Server Information Use the properties of the Server.Information class Edition IsClustered IsSingleUser Language NetName OSVersion Parent PhysicalMemory Platform Processors Product ProductLevel VersionString strEdition = myServer.Information.Edition

32 Practice: Using SMO In this practice, you will see how to: Create an SMO application Retrieve server information

33 How to Use SMO to Back Up a Database Call SqlBackup method of Backup object 5 5 Connect to SQL Server 1 1 Declare and instantiate a Backup object 2 2 Set properties of Backup object 3 3 Call Devices.Add method of Backup object 4 4

34 Demonstration: Using SMO In this demonstration, you will see how to: Use SMO to connect to a SQL Server Use SMO to list databases on a SQL Server Use SMO to create a new database

35 Lab 3: Administering SQL Server 2005 Exercise 1: Creating the Personnel Database Exercise 2: Populating the Personnel Database Exercise 3: Backing up the Personnel Database


Download ppt "Module 3: SQL Server 2005 Administrative Tools. Overview Using SQL Server Management Studio Using SQL Computer Manager Using the sqlcmd Utility Using."

Similar presentations


Ads by Google