Lesson 3: Working with SQL Server

Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes

By Ben Forta
Published by Sams
ISBN-10: 0-672-32867-4
ISBN-13: 978-0-672-32867-1

Buy this book

In this lesson, you'll learn how to connect and log into SQL Server, how to issue SQL Server statements, and how to obtain information about databases and tables.

Making the Connection

Now that you have a SQL Server DBMS and client software to use with it, it would be worthwhile to briefly discuss connecting to the database.

SQL Server, like all client/server DBMSs, requires that you log into the DBMS before being able to issue commands. SQL Server can authenticate users and logins using its own user list, or using the Windows user list (the logins used to start using Windows). As such, depending on how SQL Server is configured, it may log you in automatically using whatever login you used for Windows itself, or it may prompt you for a login name and password.

When you first installed SQL Server, you were probably prompted for an administrative login (often named sa for system administrator) and a password. If you are using your own local server and are simply experimenting with SQL Server, using this login is fine. In the real world, however, the administrative login is closely protected because access to it grants full rights to create tables, drop entire databases, change logins and passwords, and more.

To connect to SQL Server, you need the following pieces of information:

  • The hostname (the name of the computer). This is localhost or your own computer name if you're connecting to a local SQL Server.

  • A valid username (if Windows authentication is not being used).

  • The user password (if required).

If you're using one of the client applications discussed in the previous lesson, a dialog box will be displayed to prompt you for this information.

Latest Articles