Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


August 2005

SQL Server 101: Management Fundamentals

Conclude your crash course in SQL Server by learning about essential tools, security, and backup strategies
RSS
Subscribe to Windows IT Pro | See More SQL Server and Database Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!
SideBar    Importing and Exporting Data, More SQL Server Tools

If you're responsible for managing a Windows environment that includes Microsoft SQL Server—but you're not a DBA—you might feel somewhat lost in a world of tables, indexes, stored procedures, queries, and database backup. In "SQL Server 101: Essential Concepts for Windows Administrators," June 2005, InstantDoc ID 46265, I helped you start to make sense of SQL Server by explaining its fundamental concepts. In this article, I continue your SQL Server orientation by discussing the tools you need to manage a SQL Server 2000 system, SQL Server security essentials, and database backup and recovery. With these two articles under your belt, you'll know enough about SQL Server to perform necessary administrative tasks on a SQL Server 2000 system.

SQL Server Management Tools
SQL Server 2000 provides three primary tools that you can use to manage the server: Server Manager, SQL Server Enterprise Manager, and SQL Query Analyzer. The Windows Server Manager icon is displayed in the system tray; you click the icon to start, stop, or pause the SQL Server service. A green arrow over the icon indicates that the SQL Server service is running. A red square over the icon means that the service is stopped. In addition to starting and stopping SQL Server, you also use Server Manager to start and stop the SQL Server Agent, the distributed transaction coordinator (DTC), the Microsoft Search service, and Analysis Services.

Enterprise Manager, which Figure 1 shows, is the primary GUI-based SQL Server management tool. You use Enterprise Manager to manage one or multiple SQL Server instances. You start Enterprise Manager by selecting Start, Programs, Microsoft SQL Server, Enterprise Manager. You can run it directly from the server system itself, but more typically you'd install the client tools that include Enterprise Manager on a management workstation and run it from there.

To use Enterprise Manager, you must first register the server that you want to use. To register a new SQL Server system, right-click the SQL Server Group node, then select New SQL Server Registration from the pop-up menu. Doing so starts the SQL Server Registration Wizard, which prompts you for the SQL Server name and authentication information, then connects you to an instance of the server. You can use SQL Server 2000 Enterprise Manager to manage both SQL Server 2000 and SQL Server 7.0 systems, but not to manage systems running SQL Server 6.5 or earlier.

After you've registered a SQL Server system, you can view a list of all the database objects on that server, as Figure 1 shows. Right-clicking each object typically displays a pop-up menu that contains a list of relevant actions for each object. For instance, right-clicking a Tables object displays a pop-up menu that lets you create a new table, open the table designer, or retrieve rows from the table.

Query Analyzer is both a management tool and a development tool. You start Query Analyzer by selecting Start, Programs, Microsoft SQL Server, Query Analyzer. As Figure 2 shows, you can use Query Analyzer to write and execute T-SQL statements. When Query Analyzer starts, it displays a blank input window in which you type T-SQL statements. You can use Query Analyzer to build database objects by executing T-SQL Data Definition Language (DDL) statements, or you can use it to retrieve and update data by executing T-SQL Data Manipulation Language (DML) statements. After entering the T-SQL statements, you can run them either by pressing F5 or by clicking the green arrow icon on the toolbar. If the statement is a query, you'll see the results displayed in the bottom half of the screen. One important point to remember when you're running Query Analyzer is that the actions are taking place on the SQL Server system itself, not on the system on which you're running the tools.

As I mentioned earlier, you don't necessarily need to know T-SQL to maintain a SQL Server installation, but familiarity with T-SQL can be a great help. For instance, to create database objects or configure other objects such as a linked server (i.e., a link to a remote database server), it's a good idea to use T-SQL scripts that you can create and execute in Query Analyzer. A T-SQL script gives you a handy reference for the definition of all the database objects, and you can easily rerun the script to recreate the database and its object on other systems. A T-SQL script also provides a reference point that you can use to check future versions for database-object changes.

SQL Server Security
SQL Server security comprises three basic components: logins, adding database users, and granting permissions. Each component has a different role in SQL Server security. A login is required for a user to connect to the SQL Server system. If you're using Integrated Security, that login is the user's Windows username. Otherwise, the administrator must manually add a login to SQL Server. The login connects the user to the server but not to a database. To enable a user to connect to a database, you must first create a database user account for that person and add it to the database. An administrator must create a set of valid database users for each database. Likewise, accessing the database doesn't mean that a user can access the objects in that database. To allow the user access those objects, the administrator must grant the user permissions to the specific database objects. In other words, the login connects you to the server, the database user account connects you to the database, and granting permissions lets you access objects in the database. SQL Server 2000 and SQL Server 7.0 roles—which are similar to Windows groups—simplify management by letting you group similar users together.

Setting up logins is the first step in connecting your users to the server. If you're using Windows authentication, you don't need to do anything to add logins. When a user attempts to connect to the database, SQL Server authenticates the user to a Windows domain controller (DC) before SQL Server will let the user access the server. However, you need to grant the user permission to access the server by running the sp_grantlogin stored procedure. You can also use Windows groups to grant groups of users permission to log in to SQL Server. To grant all members of a group access to SQL Server, you'd run the sp_grantlogin stored procedure and specify the group name.

If you're using SQL Server authentication, you must create a SQL Server login either by running the sp_addlogin stored procedure or through Enterprise Manager. If you're using Enterprise Manager to create the login, navigate to the Server, Security, Logins node. Right-click Logins and select New Login from the pop-up menu. In the New Login dialog box, enter the login name, password, default language, and database.

Setting up a server login lets the user connect to the server but doesn't let the user access the database. To allow a server login to access a given database, you must create a database user, which you can do either through a T-SQL statement or by using Enterprise Manager. To add a new database user by using T-SQL, you use the sp_adduser stored procedure. First, run the use database command to set the correct database context. Then run the sp_adduser stored procedure, specifying an existing login name as the first parameter. To add a database user through Enterprise Manager, first expand the desired server node, then navigate to the database that you want the user to access. Expand the database node, right-click the Users node, and select the New User option from the pop-up menu.

After you've added the database user, you can then grant that user permission to access different database objects (e.g., tables, views). SQL Server supports three basic types of permissions: Grant, Deny, and Revoke. As the names suggest, Grant lets a user access an object, and Deny prohibits the object's use. Deny permission takes precedence over Grant. The Revoke permission essentially undoes whatever permission is currently in effect. In other words, it revokes a previously granted or denied permission. For each database object, you can grant or deny permissions to apply to various actions. The T-SQL keywords that you use to set Grant or Deny permissions for each object are SELECT, INSERT, UPDATE, DELETE, EXEC, and DRI.

You can manage permissions either by using the T-SQL GRANT, DENY, or REVOKE statements or through Enterprise Manager. In Enterprise Manager, expand the Users node of the database you're interested in. Then in the details pane, right-click a particular database user, then select the Manage Permissions option from the pop-up menu. A matrix is displayed that lists all the database objects at the left side of the screen and all the statements to which those permissions apply at the right. To grant a permission, click once to display a green check mark in the appropriate place in the matrix. To deny a permission, click twice to display a red X in the matrix.

   Previous  [1]  2  Next 


Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Interact! Test Your Knowledge

Learning Path A wealth of SQL Server knowledge is available at the
"SQL Server Magazine Web site"


Get started with SQL Server:
"SQL Server 101: Essential Concepts for Windows Administrators"


Gain insight into SQL Server security matters:
"SQL Server security"


Must-have reference for newbie SQL Server administrators:
"SQL Server Books Online (BOL)"


To learn more about SQL Server 2000 administration:
"Microsoft SQL Server 2000 Administrator’s Pocket Consultant"


Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

Windows Mobile: What Went Wrong?

Paul discusses the evolution of Windows Mobile and why he thinks the platform is probably doomed. ...

MacBook Announcement Proves Microsoft Is Right About 'Apple Tax'

On a day in which Apple released a long-overdue update to its notebook computer line but refused to lower prices on its expensive new hardware, Microsoft shared its thoughts about it calls "the Apple Tax." The idea, basically, is that Windows still offers ...


Related Articles SQLPing

SQL Server and Database Whitepapers StoreVault SnapManagers for Microsoft Exchange and SQL Server

It’s What You Make IT

Database Professionals: Experience Profile and Need Gaps in Development and Database Tools

Related Events Check out our list of Free Email Newsletters!

SQL Server and Database eBooks Safeguarding Your Windows Servers

SQL Server Administration for Oracle DBAs

Taking Control: Monitoring the Windows Platform Proactively

Related SQL Server and Database Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Microsoft Exchange & Windows Connections event returns to Las Vegas Nov 10 - 13
Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. Co-located with Microsoft ASP.NET, SQL Server, and SharePoint Connections with over 250 in-depth sessions.

Free Online Event! Virtualization:Get the Facts!
Register now and attend this free, live in-depth online conference on November 13 and 20, 2008, produced by Windows IT Pro. All registrants are eligible to receive a complimentary one-year digital subscription to Windows IT Pro (a $49.95 value)!

Ease Your Scripting Pains with the Flexibility of PowerShell!
Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!

PASS Community Summit 2008 in Seattle on Nov 18-21
The don’t-miss event for Microsoft SQL Server Professionals. Register now and you’ll enjoy top-notch Microsoft and Community speakers and more.



Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Email Recovery and eDiscovery for Microsoft Exchange!
Discover, Recover, and Export mailboxes, folders and individual items direct from offline EDB’s or online production Exchange Servers. Free 30 Day Demo.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing