C H A P T E R  2

SQL Server Management Studio

Now that SQL Server 2012 is successfully installed on your machine, it is time to start exploring the various areas that make this an easy and effective product to use. With SQL Server, all the administration interfaces reside in studios, such as SQL Server Management Studio, which features tools for working with developing database solutions. This chapter concentrates on SQL Server Management Studio (SSMS), which you will use to develop and maintain your databases and the objects SSMS contains.

SSMS is the graphical user interface (GUI) you will use to build your database solutions. This is an easy-to-use and intuitive tool, and before long, you will feel confident in using it to work with SQL Server quickly and efficiently. I will be discussing several aspects of SSMS in this chapter. You can then use this knowledge throughout the book. I'll discuss some aspects in more detail throughout the book.

SSMS is crucial to your success as a developer as it shows you how to build database solutions graphically. It also allows you to write and test lines of code to complete tasks that could then be placed into your programming language of choice. In Chapter 16, you will learn how you can transfer what you see demonstrated within SSMS to .NET, Excel, and Java. By the end of this chapter, you will have gained experience with it and be proficient in the following areas:

  • The components of SSMS
  • Working with the editor to enter queries

Let's start right away by having a look at SSMS and how it is used to work with SQL Server 2012.

A Quick Overview of SSMS

SQL Server runs as a separate Windows process, as touched on in Chapter 1, whether on a stand-alone desktop machine, or on a server within a network. If you open Task Manager and move to the Processes tab, you will see, among other processes, sqlservr.exe. This process or service runs in its own process space and is isolated from other processes on the machine. SQL Server should not be affected by any other piece of software that does not talk to any SQL Server component. If you have to kill any other component's process, the SQL Server engine should continue to run.

SQL Server runs as a service that is controlled and monitored by Windows. SQL Server ensures that it is given the right amount of memory, processing power, and time from the operating system by instructing Windows on what it (SQL Server) needs, although pressures on the server will mean that SQL Server will modify what it requests based on what is available. Because SQL Server runs as a service, it has no interface attached to it for a user to interact with. As a result, there needs to be at least one separate utility that can pass commands and functions from a user through to the SQL Server service, which then passes them through to the underlying database. The GUI tool that accomplishes the passing of SQL commands and functions is SSMS. You can use other tools, and you could even create your own GUI, but you'll concentrate only on SSMS within this book.

SSMS can be used to develop and work with several installations and instances of SQL Server in one application. These installations can be on one computer or on many computers connected through a local area network (LAN), a wide area network (WAN), or even the Internet. Therefore, it is possible to deal with your development, system testing, user testing, and production instances of SQL Server from one instance of SSMS. SSMS helps you in the development of database solutions, including creating and modifying components of a database, amending the database itself, and dealing with security issues. Getting to know this tool well is crucial to becoming a successful professional SQL Server developer, as well as a database administrator.

One of the tools within SSMS that you will use for completing tasks is Query Editor. This tool allows program code to be written and executed, from objects to commands that manipulate data, and even complete tasks, such as backing up the data. This program code is called Transact SQL (T-SQL). T-SQL is a Microsoft proprietary language, although it is strongly linked to the ANSI-92 SQL standard of the American National Standards Institute (ANSI). The current specification Microsoft bases its code on is ANSI-92.

Query Editor is a tool within SSMS that allows you to programmatically build the same actions as dragging and dropping or using wizards. However, using T-SQL within Query Editor can give you more control over certain aspects of certain commands. Although dragging and dropping and using wizards may be quick, as a developer knowing T-SQL allows you not only to put the T-SQL code into other languages and tools, but also to transfer your skills to many other databases. Do not underestimate the power you will gain by learning T-SQL. Note that the name “Query Editor” comes from the fact that it sends queries to the database using T-SQL. Don't worry if you don't quite grasp this—all will become clear very soon.

Spend some time taking a look at SSMS in more detail.

TRY IT OUT: TOURING SQL SERVER MANAGEMENT STUDIO

The main area of SQL Server Management Studio that you will be dealing with as a developer is Query Editor, which is covered next. It is a tabbed entry window where you have the ability to enter the code you want to execute.

Query Editor

As you progress through the book, the creation of objects, the manipulation of data, and the execution of code will be shown either by using the graphical interface and options that Object Explorer provides, or by showing code written using T-SQL. To write code, you need a free-form text editor so that you can type anything you need. Luckily, SSMS provides just such an editor as a tabbed screen within the document view on the right-hand side. This is known as Query Editor, and you can find it when you click New Query in the main toolbar or by selecting File images New images Database Engine Query.

I discussed some of the options that affect Query Editor, such as how text is entered and how results from running the T-SQL code are displayed, in the preceding section. There is not a great deal to say about the editor itself, as it really is a free-form method of entering commands and statements for SQL Server to execute, although it does have some good features that you will see as you work through the book. However, Query Editor has a toolbar that is worth covering at this point in time that is shown when you click New Query and a Query Editor window is displayed. Figure 2-12 shows this Query Editor toolbar, and Table 2-1 describes each of the toolbar options.

images

Figure 2-12. Query Editor toolbar

images

images

images

You will see and use this toolbar quite extensively within this book and throughout your development career, so it will soon become very familiar to you.

Summary

SSMS is a tool for working with SQL Server that you will see in action throughout this book, whether you're working with the graphical interface or using Query Editor to write T-SQL code. As you learned in this chapter, the main areas of the tool are the Registered Servers explorer, Object Explorer, and the main documents window that will contain graphical representations of objects in the database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.197.212