380 Part I EXAM PREPARATION APPLY YOUR KNO
380 Part I EXAM PREPARATION APPLY YOUR KNO WLEDGE Exercises 6.1 Writing a Batch That Uses a Cursor This exercise demonstrates how to write a script in SQL Server, and also demonstrates how cursors can be used to access data. Estimated time: 5 minutes 1. Open SQL Server Query Analyzer. Log in to the database you want to work with. 2. Type in the following text: DECLARE SI_Cursor CURSOR FORWARD_ONLY STATIC .FOR SELECT DISTINCT id, name FROM .sysindexes DECLARE @IndexName sysname, @ID int OPEN SI_Cursor FETCH NEXT from SI_Cursor INTO @ID, .@IndexName WHILE @@FETCH_STATUS = 0 BEGIN print Table + object_name(@id) + .has an index named + @IndexName + . FETCH NEXT FROM SI_Cursor INTO @ID, .@IndexName END CLOSE SI_Cursor DEALLOCATE SI_Cursor 3. Run the query by clicking the Play button. 6.2 Creating and Managing a Login In this exercise, you ll see how to create and manage a login in SQL Server Enterprise Manager. Estimated Time: 15 minutes 1. Open SQL Server Enterprise Manager, connect to your SQL Server, and open the Security container. Click on the Logins container. 2. Right-click in the list of logins and choose New Login. The SQL Server Login Properties New Login dialog box should appear. 3. Enter the name Doug for the login. 4. Choose SQL Server Authentication. This sets up an account that doesn t require Windows authentication. Type in a password for Doug. 5. Choose a default database for Doug. This should be the database he will use most often. Choose the Pubs database. 6. On the Server Roles tab, verify that nothing is checked. This is the list of server-fixed roles that are available. 7. Click on Database Access. On this tab, you grant Doug access to the databases he s going to be able to use. Grant Doug access to the Pubs database by clicking in the empty check box to the left of the database name. 8. After you choose Pubs, you re given the option of adding Doug to several database roles. Add Doug to the db_datareader role. This enables him to read data, but he can t change any data, and can t execute any stored procedures. 9. Click OK to create the user. Notice that Doug now shows up in the Login list. 10. Open the Databases container, open the Pubs database, and click on the Users container. Notice that Doug is a user in the database. That s what you did in step 7.
For high quality website hosting services please check tomcat web hosting website.