Tutorial: SQL Server Management Studio (SSMS) | Microsoft Docs
Total Page:16
File Type:pdf, Size:1020Kb
Table of Contents Tutorials: SQL Server Management Studio Lessons Lesson 1: Basic Navigation in SQL Server Management Studio Lesson 1-1 - Start SQL Server Management Studio Lesson 1-2 - Connect with Registered Servers and Object Explorer Lesson 1-3 - Change the Environment Layout Lesson 1-4 - Display the Query Window Lesson 1-5 - Show the Object Explorer Details Page Lesson 1-6 - Select the Keyboard Shortcut Scheme Lesson 1-7 - Set the Startup Options Lesson 1-8 - Restore the Default SQL Server Management Studio Configuration Lesson 1-9 - Summary - Basic Navigation Lesson 2: Writing Transact-SQL Lesson 2-1 - Connecting with Query Editor Lesson 2-2 - Adding Indentation Lesson 2-3 - Maximizing Query Editor Lesson 2-4 - Using Comments Lesson 2-5 - Other Ways of Viewing the Code Window Lesson 2-6 - Script a Table Lesson 3: Working with Templates, Solutions, and Script Projects Lesson 3-1 - Create Scripts Using Templates Lesson 3-2 - Create Custom Templates Lesson 3-3 - Save Scripts as Projects or Solutions Lesson 3-4 - Summary - Solutions and Script Projects Tutorial: SQL Server Management Studio 12/20/2017 • 1 min to read • Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse The SQL Server Management Studio (SSMS) tutorial introduces you to the integrated environment for managing your SQL Server infrastructure. SQL Server Management Studio presents a graphical interface for configuring, monitoring, and administering instances of SQL Server. It also allows you to deploy, monitor, and upgrade the data-tier components used by your applications, such as databases. SQL Server Management Studio also provides Transact-SQL, MDX, DMX, and XML language editors for editing and debugging scripts. What You Will Learn This tutorial will help you understand the presentation of information in SSMS and how to take advantage of its features. The best way to get acquainted with SSMS is through hands-on practice. This tutorial will teach you how to manage the components of SSMS and how to find the features that you use regularly. This tutorial is divided into three lessons: Lesson 1: Basic Navigation in SQL Server Management Studio In this lesson you will learn how to use the components of Management Studio, how to reconfigure the environment layout, and how to restore the default layout. Lesson 2: Writing Transact-SQL In this lesson, you will learn how to open Query Editor, how to manage code, and how to use other features of Query Editor. Lesson 3: Working with Templates, Solutions, and Script Projects In this lesson you will learn how to use templates, and organize scripts into solutions and projects. Requirements This tutorial is intended for experienced database administrators and database developers who are not familiar with Visual Studio, but who are familiar with database concepts and Transact-SQL. You must have the following installed to use this tutorial: Install the latest version of SQL Server Management Studio (SSMS). SQL Server 2016 or a later version with the AdventureWorks sample database. To install the AdventureWorks sample database, see AdventureWorks2014 and install the AdventureWorks2014 (OLTP) database. See Also Database Engine Tutorials Lesson 1: Basic Navigation in SQL Server Management Studio 12/20/2017 • 1 min to read • Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse Microsoft SQL Server Management Studio (SSMS) is a powerful and flexible tool. This lesson shows you how the windows work together to present a design surface that makes your work easier. At the end of this lesson, you will know how to clear unwanted windows out of your way, how to quickly bring up windows with the information you need, and how to configure the default surface to support the work you do most often. This lesson contains the following topics: Starting SQL Server Management Studio (SSMS) Connecting with Registered Servers and Object Explorer Changing the Environment Layout Display the Query Window Show the Object Explorer Details page Select the Keyboard Shortcut Scheme Set the Startup Options Restore the Default SQL Server Management Studio Configuration Summary: Basic Navigation Next Task in Lesson Start SQL Server Management Studio Lesson 1-1 - Start SQL Server Management Studio 1/17/2018 • 4 min to read • Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse To begin this tutorial, let's take a look at SQL Server Management Studio. Opening SQL Server Management Studio To open SQL Server Management Studio 1. How you start Management Studio (SSMS), depends upon your operating system. For newer versions of Windows with a Start Page, on the Start Page, type SQL Server Management Studio and the program appears. Click the program to open SSMS. You might want to right-click the program and pin it to the Start Page. For older versions of Windows, on the Start menu, point to All Programs, point to Microsoft SQL Server 2017, and then click SQL Server Management Studio. Alternately from the Run dialog box, type SSMS.exe and then click OK. NOTE If SSMS doesn't appear, you may not have successfully installed SSMS. Install SSMS from the download center. SSMS is not automatically installed with SQL Server 2016. Use the latest version to access all of the features. 2. In the next step, you connect to SQL Server using the Object Explorer component of SSMS. If the Object Explorer pane is not visible, on the View menu, click Object Explorer. In the Object Explorer menu, click the Connect button, and then click Database Engine. The Connect to Server dialog box should appear. (If you have previously installed SSMS, the user settings might be causing the Connect to Server dialog box to appear automatically.) 3. In the Connect to Server dialog box, complete the Server name box. You can connect to one of three types of SQL Server. Each type has a slightly different format for the Server name box. Pick one of the following formats: A default instance of SQL Server: When you install SQL Server on a computer, you can specify that the instance of SQL Server will be a default (unnamed instance) or a named instance. If you are connecting to a default instance of SQL Server, insert the name of the computer. For example, if you are running SSMS on a computer named Accounting and you are connecting to a default instance of SQL Server installed on that computer, type Accounting in the Server name box. A named instance of SQL Server: During setup of SQL Server, you can specify a name for the instance; for example, on a computer named Accounting, you could specify a named instance named Receivables. To connect to a named instance, in the Server name box, type the computer name backslash instance name; for example Accounting\Receivables. An Azure SQL Database: The format of the server name for SQL Database is SQL_Server_name.database.windows.net, for example mydb2.database.windows.net. If you have trouble determining your server name, visit the Azure portal for help creating a connection string. 4. In the Authentication area, select a method of authentication. If you are the administrator of the computer and just installed SQL Server, try Windows Authentication. This also works if You are configured as a domain user that has access to the SQL Server. Since the login attempt uses the credentials you used to log in to Windows, both the User name and Password boxes are grayed out. If you know the name and password of a user account, select SQL Server Authentication, and then provide the User name and Password. If you have the latest version of SSMS, you have 3 more options, starting with Active Directory Authentication. For information about these more advanced options, see Universal Authentication with SQL Database and SQL Data Warehouse (SSMS support for MFA). Management Studio Components Management Studio presents information in windows dedicated to specific types of information. Database information is shown in Object Explorer and document windows. Object Explorer is a tree view of all the database objects in a server. This can include the databases of the SQL Server Database Engine, Analysis Services, Reporting Services, and Integration Services. Object Explorer includes information for all servers to which it is connected. When you open Management Studio, you are prompted to connect Object Explorer to the settings that were last used. You can double-click any server in the Registered Servers component to connect to it, but you do not have to register a server to connect. The document window is the largest portion of Management Studio. The document windows can contain query editors and browser windows. By default, the Summary page is displayed, connected to the instance of Database Engine on the current computer. Showing Additional Windows To show the Registered Servers window 1. On the View menu, click Registered Servers. The Registered Servers window appears above or adjacent to Object Explorer. You can drag it and dock it in various locations. Registered Servers lists servers that you manage frequently. You can add and remove servers from this list. The only servers listed are the SQL Server instances on the computer where you are running Management Studio. 2. If your server does not appear, in Registered Servers, right-click Database Engine, click Tasks, and then click Update Local Server Registration. To add additional SQL Servers or a SQL Database, right-click a location in Registered Servers, and then click New Server Registration. Complete the Login area, like you completed the Connect to Server dialog box. Next Task in Lesson Connect with Registered Servers and Object Explorer Lesson 1-2 - Connect with Registered Servers and Object Explorer 1/17/2018 • 1 min to read • Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse This tutorial demonstrates the use of Registered Servers and Object Explorer.