Review Questions
Yes. You would install the appropriate Net-Library for Novell IPX/SPX on SQL Server and on the client computers on the Novell network.
ADO is easier to implement and is usually more appropriate for business application development. OLE DB provides more control over application behavior and better performance but is more difficult to implement.
Review Questions
The SQL Server services must run in the context of a Windows NT domain user account in order to use a trusted connection. The local system account cannot establish a trusted connection with any resources on a remote computer.
NWLink IPX/SPX and Multiprotocol.
Your first option is to install a separate SQL Server to support this new character set. The character set in the installed SQL Server is used for all databases on the existing server. You cannot have different character sets for different databases.
Another option is to use Unicode data types for this new database on the existing server to support the characters that are not part of the default character set.
Review Questions
First, install SQL Server 6.5 Service Pack 3 or later. Set the size of the SQL Server 6.5 tempdb database to at least 10 MB. Because there is limited disk space available, you should use a tape upgrade to transfer the data from SQL Server 6.5 to SQL Server 7 and delete the SQL Server 6.5 devices when you use the SQL Server Upgrade Wizard. Because the original devices will be deleted during the upgrade, you should back up all of the SQL Server 6.5 databases before starting the upgrade process.
It is possible that the stored procedure directly modifies a system table or references a system table or a column in a system table that does not exist in SQL Server 7. It is also possible that the object owner is not listed as a user of the database you want to update. SQL Server cannot re-create the stored procedure if the login for the object owner is missing.
SELECT t.title AS cross FROM titles t |
You want to use the BACKUP and RESTORE commands as part of maintenance jobs that you create. To allow these commands, you set the database compatibility level to 70. What impact does this setting have on your application?
You can issue BACKUP and RESTORE statements because SQL Server 7 supports these commands. However, the query in your application no longer executes correctly, because it uses the word cross as a column alias. The word cross is a reserved word for SQL Server 7. You must rewrite the query before setting the compatibility level to 70.
What type of authentication is used by default to connect to your SQL Server?
Windows NT authentication.
How can you tell whether your SQL Server is started and whether you are connected to your SQL Server?
The green arrowhead on the SQL Server icon indicates that your SQL Server is started. The vertical red zigzag line indicates that you are connected to your SQL Server.
Are any servers registered? Why or why not?
No servers are registered. When the Store User Independent check box is cleared, the shared registration information is displayed. Until you create shared registration information, there is no shared information.
What caused all of the entries in this file?
Starting SQL Server caused all of the entries. There are entries for the server starting and for each of the databases being opened and started.
Does the system log contain any entries that were generated by the installation or startup of SQL Server?
If the installation of SQL Server was successful, the Windows NT system log contains no entries for SQL Server.
Does the Windows NT application event log contain any entries that were generated by the installation or startup of SQL Server?
The Windows NT application event log contains numerous entries associated with the startup of SQL Server and SQL Server Agent. These entries relate to the entries in the SQL Server and SQL Server Agent error logs.
Review Questions
You could query the information schema views, execute system stored procedures, or use system functions. You also could query the system tables directly, but this is not advised because they may change in later product versions.
The Register SQL Server Wizard.
Yes; however, a table name is actually a combination of the owner name, the database name, and the table name. As long as the two tables are owned by two different users the names are considered unique. For example, pubs.dbo.Authors and pubs.carl.Authors are two different tables. The object name of each table is Authors, but the full table name of each table is different. While this scenario is possible, it is not a recommended practice because you cannot reference either table by the table name Authors, you would always have to use at least the object name and the owner name, so the tables would have to be referenced as dbo.Authors and carl.Authors in all queries that use them.
Sp_helpdb <database_name>.
The sysobjects table.
Review Questions
For a heavily updated database, you should either increase the size of the transaction log manually or specify enough free disk space for the log to grow automatically. Databases that are used primarily for queries typically do not require a very substantial transaction log. You might want to reduce the log size to 10 percent of the total database size.
You could use disk striping (RAID) to increase performance.
A second strategy would be to use filegroups to improve performance. In particular, place the transaction log files on a separate disk from the data files to avoid disk contention as SQL Server queries the database and records actions in the log. Also, filegroups could be used to separate a portion of the data files that require frequent backups because they are frequently modified.
If the transaction log fills, you are unable to modify the data in the database until the log is archived or expanded. To avoid a full transaction log, monitor the log space regularly, expand the log whenever necessary, set the log to grow automatically, and set an alarm to notify you when the available log space falls below a specified level. Scheduling or performing frequent transaction log dumps is the best way to reclaim available space in the transaction log.
How many rows were copied?
1341.
Did any errors occur?
Yes. Two errors were intentionally introduced into the Newprods.txt file on rows 26 and 27.
Review Questions
Use the DTS Import and DTS Export Wizards for creating simple transformations.
You can assign an owner password to the package when it is created so that no one can view or edit it. Someone can still execute the package. If you want to require a password when the package is executed, add an operator password.
You could select the DTS Import Wizard, BACKUP and RESTORE, or copy and attach the database files. Each of these methods allows you to transfer all data and objects to the new hardware. The DTS Import Wizard allows you to perform the transfer in a single operation.
Option C, adding a linked server, would work well in this scenario. Users do not need to have the Oracle client software installed on their computers, but applications can use Transact-SQL to access the table in the Oracle database directly via the linked server.
What is the meaning of the parameters @whentype = 10 and @datachg = N'TABLE = Products COLUMN = UnitsInStock'?
These parameters specify that the Web Assistant job and the necessary triggers should be created to update the Web page when data in the Products.UnitsInStock column changes.
What triggers exist?
There are three triggers named Web_Trigger_x, one each for INSERT, UPDATE, and DELETE. These triggers use the sp_runwebtask system stored procedure to execute the Web Assistant job, named Web_Trigger, when the data in the Products.UnitsInStock column changes.
Review Questions
Create a Web task to regenerate a Web page by using a trigger that determines when the underlying data tables have changed.
No. For creating dynamic Web applications, you must create Web pages that execute code on the Web server to query the database. You can do this with Active Server Pages or the Internet Database Connector running on Microsoft Internet Information Server.
You can update the Web pages immediately using SQL Server Enterprise Manager or the sp_runwebtask system stored procedure.
Create full-text indexes on the free-text data in the customer database. This will allow full-text queries on words, phrases, and derived words in all of the customer data.
The Microsoft Search service is not started. Start the service and the menus will become available.
Review Questions
SQL Server backups can occur while the database is online. However, avoid scheduling backups during times of high database activity.
Because the database exists in a single database file, you cannot back up individual parts of the database. You must back up the entire database as a single unit.
Consider a backup plan that includes database and transaction log backups. You may want to add differential backups, which shorten the backup and restore time.
Use a backup plan that starts with one database backup. A database backup will be done infrequently. Perform a backup of one of the database files each day on a rotating basis. Perform differential backups in addition to transaction log backups to minimize recovery time.
Review Questions
Try to back up the undamaged transaction log by using the NO_TRUNCATE option. This captures some of the activity since the last database backup. After you restore the database, apply the transaction log backup and recover the database.
Differential backups save time in the restore process. You can recover a database by restoring the database backup and the latest differential backup only. It is not necessary to apply all of the transaction logs or previous differential backups in order to bring the database to a consistent state.
A disadvantage of differential backups is that because differential backups do not capture intermediate changes to the database, you cannot use them to recover data from a specific point in time. You must use transaction log backups to perform point-in-time recovery.
You should find an information message stating that there was a device activation error for the C:\Mssql7\Data\Nwcopy_data2.ndf file.
What should you do to restore and recover the nwcopy database?
If possible, back up the transaction log of the damaged database, using the NO_TRUNCATE option to capture the latest activity in the log. Determine which backups are available and usable. Restore the complete database backup. Restore the latest differential backup. (This will include the changes in the first transaction log backup.) And restore the last set of transaction log backups, and recover the database.
What does the nwc3 device contain?
The nwc3 device contains a full database backup. The date and time reflect the fact that it was created before the backups on the nwchange device.
What does the nwchange device contain?
The nwchange device contains two transaction log backups, as well as a differential backup. The time stamps show that a transaction log backup was created first, followed by a differential backup and then another transaction log backup.
Notice that four backup sets are listed. SQL Server automatically selects the most recent complete database backup and the corresponding differential and/or transaction log backup sets that should be restored to return the database to a consistent state. Three out of four backups are selected (full database, differential, and one transaction log).
Do you agree that the selected backups should be restored?
Yes.
Why is the first transaction log backup not selected?
The changes recorded in this transaction log backup are reflected in the differential backup and therefore do not need to be restored from the transaction log backup.
This script determines whether the three new customers that were previously added to the Customers table were recovered.
Have all three new customers been recovered?
No, only the rows for Health Food Store and Volcano Coffee Company are in the database. Both of these rows were recorded in the differential backup. The row for The Wine Cellar was recorded in the transaction log backup, taken after the database failure. This backup set was not restored.
Review Questions
Automatic recovery occurs whenever SQL Server is restarted. It rolls transactions back or forward to maintain database integrity after a system failure.
Set the database to dbo use only. If the transaction log files and the primary data file are available, back up the transaction log so that it can be applied at the completion of the restore operation.
Set the database to dbo use only. If possible, back up the transaction log so that it can be applied at the completion of the restore operation. Replace or fix the disk. Restore the third backup file with the complete backup as the source. Restore all of the transaction log backups, specifying the NORECOVERY option for all but the last one. Restore the last transaction log backup with the RECOVERY option specified.
Set the database to dbo use only. Back up the transaction log. Restore the database, specifying the REPLACE and NORECOVERY options. Apply all but the last transaction log with the NORECOVERY option. Apply the last transaction log, specifying RECOVERY, STOPAT = 'month, xx, year, time', where time is 9:20 a.m.
If any activity occurred between 9:20 and 9:21 a.m., these changes are lost.
If possible, back up the transaction log of the production server without truncating it. Take the production server off line, and change the name of the standby SQL Server to that of the production server. Restore all available transaction logs to the standby SQL Server, and recover the database.
To what database are you connected, and why?
You are connected to StudyNwind because it was specified as the default database when you created the account.
SELECT productname FROM Products |
Did you receive any results? Why or why not?
You did receive results. Carl is a member of the db_datareader database role. All members of this role are allowed to query data in all tables in the database.
UPDATE Products SET productname = 'Tofu, unsalted' WHERE productname = 'Tofu' |
Was the update successful? Why or why not?
The update was not successful. Carl is not a member of a role that has permission to update data in StudyNwind.
Because Cathy is a member of the db_datareader and db_datawriter database roles, she is able to query and update the data. All members of these roles are allowed to query and modify data in the StudyNwind database.
Notice that you cannot provide a login name or password when you connect to SQL Server with Windows NT authentication and that your user name is displayed in the title bar of the query window.
How did Carl connect to the database when his Windows NT login was not authorized to use SQL Server?
Carl is a member of the STUDYSQL\Customer_mgmt group in Windows NT, which has been authorized to use SQL Server.
What happens and why?
Max is denied access to SQL Server. He is a valid Windows NT user, but he has not been authorized to use SQL Server and does not belong to a Windows NT group that has been authorized to access SQL Server.
Review Questions
They can connect to the server and query some system tables but cannot gain access to any user databases.
Mixed Mode because the UNIX connections are not trusted.
USE StudyNwind GO CREATE VIEW test_view as SELECT firstname, lastname FROM Employees |
Were you able to create the view?
Yes, because permissions have been granted to Cathy to create views.
USE StudyNwind CREATE TABLE testtable (column1 INT NOT NULL, column2 CHAR(10) NOT NULL) |
Did the statement execute successfully? Why or why not?
The CREATE TABLE statement failed because Cathy does not have statement permissions that allow her to execute it.
USE StudyNwind SELECT * FROM Customers SELECT * FROM Categories SELECT * FROM Products SELECT * FROM Orders |
Which tables can Carl query? Which tables is he not able to query? Why?
He can query all of the tables because he is a member of the db_datareader fixed database role.
USE StudyNwind SELECT * FROM Customers SELECT * FROM Categories SELECT * FROM Products SELECT * FROM Orders |
Which tables can Umberto query? Which tables is he not able to query? Why?
He can query only the Categories and Products tables. He can query these tables because permissions have been granted to the public role. He cannot query any other tables, because permissions have not been given to the public role, his own account, or any roles or groups to which he belongs (they are in the revoked state).
USE StudyNwind SELECT * FROM Customers SELECT * FROM Categories SELECT * FROM Products SELECT * FROM Orders |
Which tables can Carl query? Which tables is he not able to query? Why?
He can no longer query the Customers table because he is a member of the Cust_Mgmt role, which has been denied permissions, overriding the db_datareader permissions. He can no longer query the Categories table because the public role has been denied permissions, overriding the db_datareader permissions. He can still query the Products and Orders tables because he is a member of the db_datareader fixed database role.
USE StudyNwind SELECT * FROM Customers SELECT * FROM Categories SELECT * FROM Products SELECT * FROM Orders |
Which tables can Umberto query? Which tables is he not able to query? Why?
He can no longer query the Categories table because permissions have been denied to the public role. He cannot query the Customers or Orders tables because permissions have not been given to the public role, his own account, or any roles or groups to which he belongs (they are in the revoked state). He can query the Products table because permissions have been granted to the public role.
USE StudyNwind SELECT * FROM Customers SELECT * FROM Categories SELECT * FROM Products SELECT * FROM Orders |
Which tables can Carl query? Which tables is he not able to query? Why?
He can again query the Customers table because the deny to the Cust_Mgmt role has been revoked, allowing him to have the db_datareader permissions. He can again query the Categories table because the deny to the public role has been revoked, allowing him to have the db_datareader permissions. He can still query the Products and Orders tables because he is a member of the db_datareader fixed database role.
USE StudyNwind SELECT * FROM Customers SELECT * FROM Categories SELECT * FROM Products SELECT * FROM Orders |
Which tables can Umberto query? Which tables is he not able to query? Why?
He can no longer query the Products table because permissions have been revoked from the public role and permissions have not been given to the public role, his own account, or any roles or groups to which he belongs (they are in the revoked state). He still cannot query the Categories table. Although permissions are no longer denied to the public role, permissions have not been given to the public role, his own account, or any roles or groups to which he belongs (they are in the revoked state). He still cannot query the Customers or Orders tables because permissions have not been given to the public role, his own account, or any roles or groups to which he belongs (they are in the revoked state).
SELECT * FROM Employee_View |
Were you able to query the view? Why or why not?
Yes, you can query the view, even though Umberto does not have permissions on the underlying table. This is because the table and the view have the same owner.
EXEC Employee_Proc |
Were you able to execute the stored procedure? Why or why not?
Yes, you can execute the stored procedure, even though Umberto does not have permissions on the underlying table. This is because the table and the stored procedure have the same owner.
SELECT * FROM Employees |
Were you able to query the table? Why or why not?
No. Umberto has permissions that allow him to use only the Employee_ View view and the Employee_Proc stored procedure because those permissions have been granted to the public role. SELECT privileges have not been granted to the public role for Employees.
SELECT * FROM Employees SELECT * FROM Customers |
What permissions does Carl have after the Order_Entry application role is activated?
Carl has only the permissions that are associated with the Order_Entry role. An application role is exclusive; any other permissions that Carl has directly or in other roles of which he is a member will be ignored (except fixed server roles). For example, Carl can query the Employees table through his membership in the db_datareader role, but these permissions are ignored after an application role is activated.
How long will the Order_Entry role be activated for Carl?
The Order_Entry application role remains active until the session (connection) is closed or until the user changes to another database.
Review Questions
When that login account maps to a Windows NT group that requires common permissions.
At all times. Use the sa login only for installing SQL Server and for recovery in the event that the members of the sysadmin role are dropped inadvertently.
No. Denial of permissions to the role supersedes granting of permissions to the security account.
What information is displayed in the job history when Show Step Details is selected? What information is displayed when this option is cleared?
Show step details provides information (error messages and notifications) on each job step and the outcome. When the option is not checked, only the outcome is displayed.
What do you notice in the history?
After the first step failed, it executed again according to the retry interval. The error message from step 1 is "Unable to open BCP host data-file."
What information is displayed in the log?
SQL Server Agent is the event source. The event category is Job Engine. The description includes the name of the job, who invoked the job, the job failure message, and the step number of the last step to run.
What information is displayed in the output file?
The command-prompt output, including the SQLState error number, native error number, and error message "Unable to open BCP host data-file."
Did a SQL Mail session start successfully?
No. An error was received indicating that it failed to start.
What was the source of the error messages associated with SQL Mail?
ODS reported a MAPI login failure.
Did the SQL Mail session start successfully?
Yes.
What was the query result?
Product Total of 77.
What additional responses to the alert can be defined that were not included as part of the wizard?
Execute a job, notify additional operators, specify additional notification message to send to operator, and delay between responses.
USE StudyNwind EXEC reorder @prodid = 2 |
Did you receive the defined notifications in response to the alert?
Yes. A net send command message and e-mail message were received.
What information is displayed in the output file?
The command prompt output from the successful BCP, stating that five rows were copied.
Review Questions
Create one job to back up the transaction log, and specify two schedules.
The first step is to create a custom error message that specifies the customer account name, credit limit, remarks (assuming that the column already exists in the database), and the name of the customer representative who made the update.
The next step is to modify the stored procedure or trigger that changes customer credit limits to raise the custom error with the RAISERROR statement.
Then you would create the customer account manager as an operator.
Finally, you would create an alert on the custom error message that sends an e-mail message to the customer account manager when the alert is fired.
Create a performance condition alert on the Lock Wait Time (ms) counter of the SQLServer:Locks object.
Watch the Chart window while the monitoring batch files execute. What trends do you notice?
Observations will vary. The cache-hit ratio may rise almost immediately and remain high. Index searches and full scans are taking place. The number of batch requests will rise and then stabilize. The Percent Log Used and Total Transactions counters will rise.
What trends do you notice?
Observations will vary. The Memory/Faults/sec counter remains high, while the Memory/Pages/sec counter remains low. Windows NT is paging, but much of the data is already in main memory (on a standby list) and does not need to be brought in from disk. The Process/Faults/sec/SQL Server counter is low, indicating that SQL Server is performing some paging. The Process/%Processor Time/SQL Server counter indicates that SQL Server is using only a portion of the total processor time.
What information is recorded?
You should see the failed login attempts for Maria and sa.
What information is recorded?
You should see all of the events associated with making a connection from SQL Server Query Analyzer. Notice that SQL Server Query Analyzer submits several queries as part of the startup process. It uses the information that it requests to establish the session and populate the user interface. For example, the query "select name from master..sysdatabases order by name" is used to populate the DB drop-down box in SQL Server Query Analyzer.
What events are included?
You should see disconnect events, as well as the execution of several queries. The queries include system stored procedures (sp_help), as well as some complex queries that use tables from the nwcopy database.
What is the query text?
Answers may vary; however, the following query will be among the worst performers:
SELECT e.lastname, p.productname, avg(d.quantity * d.unitprice) FROM employees e JOIN orders o ON e.employeeID = o.employeeid JOIN [order details] d ON o.orderid = d.orderid JOIN products p ON d.productid = p.productid GROUP BY e.lastname, p.productname |
Were table scans used to process this query? What can be done to improve performance?
This query requires several table scans in order to join the Products, Order Details, Employees, and Orders tables. Creating appropriate indexes will likely improve the performance of this query.
EXEC sp_helpindex Employees EXEC sp_helpindex Orders EXEC sp_helpindex [Order Details] EXEC sp_helpindex Products |
What indexes exist on the Employees, Orders, Order Details, and Products tables?
None; the nwcopy database has no indexes.
Using the spid recorded in step 3, identify what locks were granted to the transaction that was issued by connection 2.
Locks that are held should include the following: a shared database lock (Type _ DB, Mode _ S), an intent page lock (Type - PAG, Mode - IX), and an exclusive row lock (Type - RID, Mode - X).
Does the query complete?
No, the query is waiting.
Is the spid for connection 3 waiting for any resources? (Look for WAIT in the Status column.)
Yes, it is waiting for a lock to be granted on the row to be updated.
Why can't connection 3 complete the query?
The row to be updated is exclusively locked by connection 2. Both the sp_lock procedure and the Current Activity window show that the spid for connection 3 is waiting for the row lock to be released.
Review Questions
First, determine whether the problem is due to a load on the system as a whole or on SQL Server alone. To do this, use SQL Server Performance Monitor to compare the resource use of Windows NT with that of SQL Server.
If the problem is due to SQL Server activity, create a trace by using SQL Server Profiler to record the activity that occurs around 2 p.m. every day. This trace should look at events that might increase the load on the server, such as user connections, Transact-SQL statements, stored procedures, or use of the tempdb database. Consider grouping this information by duration and by application or user.
With this information, you can determine which events are placing the greatest load on the system.
On a table level, you can use SQL Server Profiler, the sp_lock and sp_who system stored procedures, and Current Activity in SQL Server Enterprise Manager.
First, generate the estimated execution plan for the query. This does not actually execute the query. Statistical information cannot be generated unless the query is executed. You then must execute the query with statistics turned on. You can show the execution plan when you execute the query to see the actual execution plan.
Review Questions
At a minimum, you should consider transactional consistency, latency, site autonomy, security, existing data sources, data update frequency, performance, administration, and whether to allow updating Subscribers.
The best way to address these requirements would be to combine two of the replication models. You could have a Central Subscriber in each region that would collect all of the daily sales information for the region. The regional Central Subscribers could then publish the data to company headquarters at night. By using a single Central Subscriber/Publisher in each region, you minimize the long-distance communication costs.
The job called SQLSERVER-StudyNwind-StudyNwind_Products_Pub-SQLSERVER-PullSubs- 0, with a category of REPL-Distribution, is the job that starts the Distribution Agent for your new subscription.
Which server's system resources will this job consume? Would a push subscription change the resources being used?
This job will consume the system resources of the Subscriber. If a push subscription were used, the system resources of the Distributor would be used. For the purposes of this exercise, the Subscriber and the Distributor are on the same computer, but normally they would be on different computers.
Whose system resources does this Merge Agent consume? Would a pull subscription change the resources that are used?
This Merge Agent consumes the system resources of the Distributor. A pull subscription would use the system resources of the Subscriber. For the purposes of this exercise, the Subscriber and the Distributor are on the same computer, but normally they would be on different computers.
USE StudyNwind UPDATE Customers SET ContactName = 'Maria Anders-Smith' WHERE CustomerID = 'ALFKI' SELECT * FROM Customers |
How long will it take for this update to be replicated?
It will take up to two minutes for these updates to be replicated, based on the schedule that was set in the previous exercise.
SELECT * FROM Customers |
Which update was applied? Was it the update made on the Publisher server (in the StudyNwind database) or on the Subscriber server (in the nwrepl database)?
The update made on the Publisher server was applied. Updates made at the Publisher will always "win" over conflicting updates made at Subscribers. Which Subscriber will win when conflicting updates are made at different Subscribers depends on Subscriber priorities or custom resolvers.
To resolve the conflict
SELECT * FROM Customers |
Was the revised data applied to both servers?
Yes.
Review Questions
First make sure that the network between the two servers is running. Then check the account that SQL Server is using for replication (the default is SQL Server Agent). Make sure that this account has access to the other server. Finally, check that the schedule for the various agents is correct, and possibly start the initial synchronization manually.
The number of Publishers, publications, and Subscribers; the amount of data that will be changing; the frequency of data changes; the type of replication that is used; the latency; and whether Subscribers are anonymous.
The best model and method would be a single Publisher using a remote Distributor (on a separate computer) that allows read-only Subscribers and Subscribers with the Immediate Updating Subscribers option. For offline Subscribers, you should allow read-only Subscribers or merge replication. For online Subscribers, you would enable the Immediate Updating Subscribers option. Using this option will add some extra processing on the Publisher, however.
What is the function of this agent and how often does it run?
Agent | Function | Schedule |
---|---|---|
Agent history clean up: distribution | Removes replication agent history from the distribution database | Every 10 minutes |
Distribution clean up: distribution | Removes replicated transactions from the distribution database | Every 10 minutes |
Expired subscription cleanup | Detects and removes expired subscriptions from published databases | Daily at 1:00 a.m. |
Reinitialize subscriptions having data validation failures | Reinitializes all subscriptions that have data validation failures | On demand, or in response to an alert |
Replication agents checkup | Detects replication agents that are not actively logging history | Every 10 minutes |
Review Questions
Use SQL Server Performance Monitor and view the Repl. Pending Xacts counter of the SQLServer:Databases object.
Check the SQLServerAgent service to make sure that it is running and configured properly. Also check the distribution database and the SQL Server Agent logs.
View the agent histories and check each agent to determine whether it was successful.