Académique Documents
Professionnel Documents
Culture Documents
Two Minute
SQL Server Stumpers
Test your SQL Server 2005 knowledge!
Vol. 4
Vol. 4
And
Jamie Thomson
Jon Reade
Central Publishing Group
P.O. Box 9510
Fleming Island, FL 32006
Copyright Notice
Copyright 2006 by The Central Publishing Group. All rights reserved.
Except as permitted under the Copyright Act of 1976, no part of this
publication may be reproduced under the Copyright Act of 1976. No
part of this publication may be reproduced in any form or by any means
or by a database retrieval system without the prior written consent of
The Central Publishing Group. The publication is intended for the
audience of the purchaser of the book. This publication cannot be
reproduced for the use of any other person other than the purchaser.
Authors of the material contained in this book retain copyright to their
respective works.
Disclaimer
The Central Publishing Group and the individual authors of the
questions and answers are not liable for any problems or issues
resulting from using this information. It is intended strictly as a
learning aid and is not a final source of reference.
Trademarks
Microsoft, SQL Server, Windows, .NET, and Visual Basic are
registered trademarks of Microsoft Corporation.
Forward
The INTERVIEW.
Steve Jones
SQLServerCentral.com
Question 1 - Administration
When using Multiple Active Result Sets (MARS) and submitting
multiple requests across a single connection, when does the
server stop processing one request and move to the next?
Choose one of the answers below:
1. Restore the database, then re-run the full text indexing process.
2. Restore the database.
3. Restore the database, drop and add back the full text indexes.
4. Restore the full text indexes from backup, then restore the database.
Answer:
2. Restore the database.
In SQL Server 2005, the full text catalogs are backed up along with the
databases, so a simple restore would bring back the catalog.
Ref: SQL Server 2005 Full-Text Search: Internals and Enhancements -
http://msdn.microsoft.com/en-us/dnsql90/html/sql2005ftsearch.asp
Question 3 - Replication
You are having trouble with all of the command prompt utilities
on your SQL Server 2000 server. There must be an
environmental variable or something set improperly as osql,
itwiz, isql, makepipe and more are not working. You decide that
you will just use Enterprise Manager to setup snapshot
replication and run your pre and post T-SQL batches instead of
scripting everything. What will be the problem?
Choose one of the answers below:
1. Enterprise Manager doesn't allow running pre and post scripts. You
will need to run these in QA manually before and after working on the
snapshot replication.
2. Pre and post scripts are affected by a bug in Enterprise Manager and
will never complete.
3. Pre and post scripts depend on osql to run and you will not be able to
run them because of that.
4. The snapshot process requires isql and therefore will not work.
Answer:
3. Pre and post scripts depend on osql to run and you will not be able to
run them because of that.
Pre and post scripts in snapshot replication are run using osql and
therefore will not execute on this server.
Ref: Executing Scripts Before and After the Snapshot is Applied -
http://msdn.microsoft.com/library/en-
us/replsql/replimpl_688e.asp?frame=true
Question 4 - SQL Server 2005
What does SMO mean in SQL Server 2005?
Choose one of the answers below:
1. Yes
2. No
3. Only when a full backup occurs on the principal database.
Answer:
2. No
You do not need to do this. Backing up the mirror database is not
supported in SQL Server 2005.
Ref: Database Mirroring - http://msdn2.microsoft.com/en-
us/library/ms189053.aspx
Question 7 - SQL Server 2005
What is the role of a witness in database mirroring?
Choose one of the answers below:
Ref: - http://msdn2.microsoft.com/en-us/library/ms187757.aspx
Question 9 - SQL Server 2005
What does MARS stand for in SQL Server 2005?
Choose one of the answers below:
1. No
2. Yes
Answer:
1. No
The schema is not the same as the owner in SQL Server 2005. While
they are similar in that they both are containers of objects, the owner
could not be dropped in SQL Server 2000, but it acted as the container
for objects. In SQL Server 2005, the owner can be associated with a
schema, but the schema is the container for objects. The owner is
separate and can be dropped without affecting the schema and it's
objects.
Ref: User-Schema Separation - http://msdn2.microsoft.com/en-
us/library/ms190387(SQL.90).aspx
Question 11 - SQL Server 2005
Which of the following error functions is not valid in SQL Server
2005?
Choose one of the answers below:
1. error_level()
2. error_line()
3. error_state()
4. error_number()
Answer:
1. error_level()
The following functions are valid in SQL Server 2005:
error_number()
error_message()
error_severity()
error_state()
error_line()
error_procedure()
1. 4
2. 8
3. 16
4. 32
5. No Limit
Answer:
5. No Limit
5. There is no limit to how many CPUs SQL Server 2005 Enterprise
Edition will support.
Ref: SQL Server 2005 Features -
http://www.microsoft.com/sql/prodinfo/features/compare-
features.mspx.
http://www.sqlservercentral.com/columnists/bknight/comparisonofsqls
erver2005editions.asp - Comparison of SQL Server 2005 Editions By
Brian Knight, SQL Server Central, 28th February 2005.
Question 14 - SQL Server 2005
You are working with SQL Server 2005 and you wish to call an
external program on your server from within the SQL Server.
You receive this message:
Msg 15501, Level 16, State 1, Procedure xp_cmdshell,
Line 1
This module has been marked OFF.
Turn on 'xp_cmdshell' in order to be able to access
the module.
What can you do to fix it?
Choose one of the answers below:
1. Run this:
EXECUTE sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXECUTE sp_configure 'xp_cmdshell', '1'
GO
RECONFIGURE WITH OVERRIDE
GO
1. Enterprise only
2. Enterprise and Standard
3. Enterprise, Standard and Workgroup
4. Enterprise, Standard and Developer
5. All editions except Express
Answer:
4. Enterprise, Standard and Developer
SQL Server 2005 Enterprise, Standard and Developer Edition all
support database mirroring. Note that only up to 2 CPUs per server are
supported wih the Standard Edition.
Ref: SQL Server 2005 Features -
http://www.microsoft.com/sql/2005/productinfo/sql2005features.asp.
http://www.sqlservercentral.com/columnists/bknight/comparisonofsqls
erver2005editions.asp - Comparison of SQL Server 2005 Editions By
Brian Knight, SQL Server Central, 28th February 2005.
Ref: SQL Server 2005 Features Comparison -
http://www.microsoft.com/sql/prodinfo/features/compare-
features.mspx
Question 16 - SQL Server 2005
What is the maximum amount of RAM supported by SQL Server
2005 Standard Edition? Submitted by Jon Reade.
Choose one of the answers below:
1. 3GB
2. 2GB
3. 8GB
4. 4GB
5. No Limit
Answer:
5. No Limit
There is no limit on how much RAM the Standard Edition of SQL
Server 2005 can utilize. The limitation is the support by the host
operating system.
Ref: SQL Server 2005 Features -
http://www.microsoft.com/sql/2005/productinfo/sql2005features.asp.
http://www.sqlservercentral.com/columnists/bknight/comparisonofsqls
erver2005editions.asp - Comparison of SQL Server 2005 Editions By
Brian Knight, SQL Server Central, 28th February 2005.
Question 17 - SQL Server 2005
The SQL Server 2005 Service Broker implements what type of
service?
Choose one of the answers below:
1. This is the SQL Server 2005 Full Text Search Engine service.
2. This is the SQL Server 2005 service that loads and manages word
breakers, stemmers, indexers, and other third party components for Full
Text Search.
3. This is the SQL Server 2005 service that manages the full time
Engine Data Protection.
4. This is the Profiler service that runs full time collecting all event
data.
Answer:
2. This is the SQL Server 2005 service that loads and manages word
breakers, stemmers, indexers, and other third party components for Full
Text Search.
MSFTEFD is the full-text filter daemon safely loads and drives third-
party extensible components used for index and query, such as word
breakers, stemmers, and filters, without compromising the integrity of
the full-text engine service itself.
Ref: SQL Server 2005 Full-Text Search: Internals and Enhancements -
http://msdn2.microsoft.com/en-us/library/ms142541.aspx
Question 21 - SQL Server 2005
When submitting multiple requests across a single connection
using MARS, how many threads are used to process the
requests?
Choose one of the answers below:
1. One
2. One per request
3. All available threads in the worker pool, no more than 1 per thread.
4. All available threads needed in the worker pool to take advantage of
parallelism.
Answer:
1. One
All the requests across a single connection are limited to one spid and
in most cases, one thread. A particular batch could be executed using
parallelism, but two different batches will not run in parallel. They may
switch execution at well defined points, but in general will run one at a
time.
Ref: http://msdn2.microsoft.com/en-us/library/ms345109.
Question 22 - SQL Server 2005
In SQL Server 2005 execution plans, what operation is
equivalent to a SQL Server 7.0/2000 "Bookmark Lookup" on a
heap? Submitted by Adam Machanic
Choose one of the answers below:
1. Yes
2. No
Answer:
2. No
You cannot use the mirror database. The mirror database is perpetually
in "recovering" mode and is unusable. You could, however, setup a
database snapshot from the mirror and use that.
Ref: Mirroring States - http://msdn2.microsoft.com/en-
us/library/ms189284.aspx
Database Mirroring and Database Snapshots -
http://msdn2.microsoft.com/en-us/library/ms175511.aspx
Question 27 - SQL Server 2005
What does this return?
select * from INFORMATION_SCHEMA.ROUTINES
Choose one of the answers below:
1. 100 ft
2. 1000 feet
3. same continent
4. No limit
Answer:
4. No limit
Since the communcations between the primary and mirror are network
based and no equipment is shared, there is no distance limitation for the
two servers.
Ref:
http://www.microsoft.com/technet/prodtechnol/sql/2005/dbmirror.msp
x
Prerequisites and Recommendations for Database Mirroring -
http://msdn2.microsoft.com/en-us/library/ms366349.aspx
Question 29 - SQL Server 2005
In SQL Server 2005, which of the following is a centralized user
interface for managing database servers, Analysis Services,
SQL Server CE solutions, and Reporting Services servers?
Submitted by Asa Jhunnejah
Choose one of the answers below:
1. EncryptByPassPhrase()
DecryptByPassPhrase()
2. EncryptByPassword()
DecryptByPassword()
3. EncryptWithKey()
DecryptWithKey()
4. EncryptText()
DecryptText()
Answer:
1. EncryptByPassPhrase()
DecryptByPassPhrase()
There are two new functions, EncryptByPassPhrase() and
DecryptByPassPhrase(), that leave the key management to you. Each of
these takes a phrase, which can be words, numbers, or plain readable
English, and uses that to encrypt plain text or decrypt some values.
Note that the encrypted text is returned as a varbinary result. An
example:
declare @plaintext varchar(1000)
, @phrase varchar(40)
, @encrypted varbinary( 1000)
, @decrypt varchar(1000)
1. Yes
2. Yes, but only for non-administrative users.
3. No
Answer:
1. Yes
Yes, each login has on the Properties General tab two checkboxes. One
to enforce the Password policy for this user and one to enforce the
password expiration for this user.
Ref: Password Policy - http://msdn2.microsoft.com/en-
us/library/ms161959.aspx
Question 38 - SQL Server 2005 - Security
In SQL Server 2005, you can create and integrate CLR objects
into the database. These objects can be .NET assemblies that
are referenced through stored procedures, functions, etc. There
are 3 levels of security for each assembly. What are they?
Choose one of the answers below:
1. Encrypt(Cert_ID('MyUserCertificate'), @data)
2. EncryptByCert('MyUserCertificate', @data)
3. EncryptByCert(Cert_ID('MyUserCertificate'), @data)
4. Encrypt( MyUserCertificate, @data)
Answer:
3. EncryptByCert(Cert_ID('MyUserCertificate'), @data)
Once you have created a certificate, the EncryptByCert function can
use this certificate to encrypt data. The certificate ID must be used and
this is returned by the cert_id() function.
Ref: - http://msdn2.microsoft.com/en-us/library/ms188061.aspx
Question 41 - SQL Server 2005 - Security
You are working with SQL Server 2005 and wish to create a
certificate for a contractor to use for a limited time. Which one of
these answers will do this?
Choose one of the answers below:
1.
CREATE CERTIFICATE Contractor1Cert
AUTHORIZATION Contractor1 WITH subject =
'Certificate For Contract #1',
EXPIRY_DATE = '12/31/2005',
ENCRYPTION BY PASSWORD =
'q%dsabciJ&#QZk#wM5G!WB36z5m7'
2.
CREATE CERTIFICATE Contractor1Cert
WITH ENCRYPTION BY PASSWORD =
'q%dsabciJ&#QZk#wM5G!WB36z5m7'
GO
GRANT AUTHORIZATION TO Contractor1 on Contractor1Cert
UNTIL '12/31/2005'
3.
CREATE CERTIFICATE Contractor1Cert
AUTHORIZATION Contractor1 WITH subject =
'Certificate For Contract #1',
ENCRYPTION BY PASSWORD =
'q%dsabciJ&#QZk#wM5G!WB36z5m7'
go
sp_add_job @start_time='12/31/2004', @cmd='delete
Contractor1Cert'
Answer:
1.
CREATE CERTIFICATE Contractor1Cert
AUTHORIZATION Contractor1 WITH subject =
'Certificate For Contract #1',
EXPIRY_DATE = '12/31/2005',
ENCRYPTION BY PASSWORD =
'q%dsabciJ&#QZk#wM5G!WB36z5m7'
To limit the time frame for a certificate, you use the EXPIRY_DATE
parameter of the CREATE CERTIFICATE command.
Ref: - http://msdn2.microsoft.com/en-us/library/ms187798.aspx
Question 42 - SQL Server 2005 - Security
Under which account does the SQL Server 2005 Full Text
Search service run?
Choose one of the answers below:
1. LocalSystem
2. The service account used for the default instance.
3. The service account used for that instance's SQLAgent.
4. The service account used for that instance's SQL Server engine.
Answer:
4. The service account used for that instance's SQL Server engine.
In SQL Server 2005, the full-text engine is synchronized to use the
same account as the Database Engine (as opposed to LocalSystem),
making it is easier to deploy full-text search functionality in a locked-
down environment, yet the side-by-side approach ensures there is no
risk of the side effects that can be introduced in a shared-service
setting.
Ref: SQL Server 2005 Full-Text Search: Internals and Enhancements -
http://msdn.microsoft.com/en-us/dnsql90/html/sql2005ftsearch.asp
Question 43 - SQL Server 2005 - Security
You are working with SQL Server 2005 and decide to use an
application role. During your testing, you invoke the application
role, only to find a problem. To return to your administrative role,
what can you do?
Choose one of the answers below:
1. You can only close your session and then reconnect with a new
session to fix the app role.
2. You can run sp_unsetapprole, provided that you have saved the
output of sp_setapprole in a cookie.
3. You can run sp_unsetapprole and it will return your permissions to
your login account.
4. You can run SETUSER and return to your previous login.
Answer:
2. You can run sp_unsetapprole, provided that you have saved the
output of sp_setapprole in a cookie.
In SQL Server 2005, you can "unset" an application role using
sp_unsetapprole, but you must have previously saved a cookie from
sp_setapprole. The calls (before and after) would be:
DECLARE @myCookie varbinary(256)
EXEC sp_setapprole 'myapp', 'PasswordHere',
@fCreateCookie = true, @cookie = @myCookie OUTPUT
-- You are now running the app role
-- now, unset it
EXEC sp_unsetapprole @myCookie
Ref: sp_unsetapprole - http://msdn2.microsoft.com/en-
us/library/ms365415.aspx
Question 44 - SQL Server 2005 - Security
You are working with SQL Server 2005 and want to take
advantage of the new security policies in your company.
Specifically, you are concerned about the consultants that you
employ. Your company uses a number of different consultants
for short term projects, often calling the same person back for
additional work. However there are long lapses between any one
person working on your systems. What is the best way to handle
this?
Choose one of the answers below:
3. Run the following for all logins (Steve is a sample login) when they
are done working:
disable login Steve
Run this when they are called back:
enable login Steve
4. Run the following for all logins (Steve is a sample login) when they
are done working:
sp_loginoption('disable','Steve')
Run this when they are called back:
sp_loginoption('enable','Steve')
Answer:
2. Run the following for all logins (Steve is a sample login) when they
are done working:
alter login Steve disable
Run this when they are called back:
alter login Steve enable
SQL Server 2005 includes the ability to alter a login and disable it's use
for a time and then alter re-enable the login, preserving all permissions.
The syntax to disable is:
alter login Steve disable
and to re-enable the login
alter login Steve enable
Ref: ALTER LOGIN - http://msdn2.microsoft.com/en-
us/library/ms189828.aspx
Question 45 - SQL Server 2005 - Security
User Test1 owns 3 schemas in a SQL Server 2005 database.
They are named MyTest, MyOtherTest, and StillAnotherTest.
Test1 has their default schema set to MyTest and is a ddladmin.
They create a table as follows:
create table StillAnotherTest.MySecond
( MyID int
, MyChar varchar(10)
)
go
The user then executes the following:
select * from MySecond
What happens (there is no MySecond table owned by any other
schema)?
Choose one of the answers below:
1. The user receives a result set of the rows in the MySecond table.
2. The user receives an permissions error because explicit SELECT
permissions were not granted to him on this table even though he owns
it
3. The user receives an "Invalid Object" error because the schema is
not listed.
4. The user receives a list of rows that they have added to the table, but
rows added by dbo or others are filtered out.
Answer:
3. The user receives an "Invalid Object" error because the schema is
not listed.
When a user executes a query with a one-part name, the server checks
the following schemas:
• sys
• the user's default schema
• dbo
Since this table is not in the user's default schema, a Msg 208, "Invalid
Object Name" error is generated. Issuing a "Select * from
StillAnotherTest.MySecond" would return all rows from the table.
Ref: User-Schema Separation - http://msdn2.microsoft.com/en-
us/library/ms190387.aspx
Question 46 - SQL Server 2005 - Security
User test1 is in the db_ddladmin role, but not db_owner is a SQL
Server 2005 database. He executes the following:
create table dbo.MySecond
( MyID int
, MyChar varchar(10)
)
go
What happens?
Choose one of the answers below:
1. The table is created as dbo.MySecond and all rows are returned from
this table.
2. The table is not created as the user cannot impersonate dbo without
being db_owner.
3. The table is created as dbo.MySecond, but the select fails because
the user has not been granted SELECT rights on the table.
4. The table is created as test1.MySecond and all rows are returned.
Answer:
3. The table is created as dbo.MySecond, but the select fails because
the user has not been granted SELECT rights on the table.
While a ddl_admin can create tables owned by the dbo schema, without
explicit permissions granted for SELECT, the user cannot actually
retrieve data from that table.
Ref: User-Schema Separation - http://msdn2.microsoft.com/en-
us/library/ms190387.aspx
Question 48 - SQL Server 2005 - Security
New user test1 has been granted ddl_admin, but not db_owner
in a SQL Server 2005 database. The user executes the
following:
create table dbo.MySecond
( MyID int
, MyChar varchar(10)
)
go
grant select on dbo.MySecond to test1
select * from MySecond
What happens?
Choose one of the answers below:
3. Run profiler and look for connection events and note the protocol.
Answer:
2. Run
select *
from sys.dm_exec_connections
where auth_scheme = 'sql'
There are a new set of adminstrative tools called Dynamic Management
Views, one of which is dm_exec_connections under the sys schema.
This view has a column called auth_scheme that will contain 'NTLM'
or 'SQL' depending on the method the connection used.
Dynamic Management Views -
http://www.sqlteam.com/item.asp?ItemID=23040
sys.dm_exec_connections - http://msdn2.microsoft.com/en-
us/library/ms181509.aspx
Question 50 - SQL Server 2005 - Security
User test1 owns the StillAnotherTest schema, which is the
default for this user. There are two tables in this database,
StillAnotherTest.MySecond and dbo.MySecond, to which user
test1 has insert and select permissions. The tables are empty
and test1 executes this:
insert dbo.MySecond select 1, 'A'
insert StillAnotherTest.MySecond select 2, 'B'
select * from MySecond
What is returned?
Choose one of the answers below:
1. The first insert fails because the user does not own the schema, but
the second is completed and "2" and "B" are returned in a two column
result set.
2. Both inserts complete and "2" and "B" are returned in a two column
result set.
3. Both inserts completeand "1" and "A" are returned in a two column
result set.
Answer:
2. Both inserts complete and "2" and "B" are returned in a two column
result set.
The user has been granted INSERT and SELECT permissions to both
tables, so both inserts will complete. The one part name of
"MySecond" in the query causes the server to look for tables in this
order:
• sys.MySecond
• StillAnotherTest.MySecond
• dbo.MySecond
1. syslogins
2. sysxlogins
3. sys.server_principals
4. sys.sql_logins
Answer:
4. sys.sql_logins
The syslogins view is a hold-over from SQL Server 2000 and is
included for backward compatibility. As a result, it displays
information we’re used to seeing in SQL Server 2000, meaning there is
no additional information on password policy or expiration. The
sysxlogins table did come over in SQL Server 2005 and any queries
against it will result in an “invalid object name” error. While
sys.server_principals is a valid catalog view in SQL Server 2005, it
does not contain the information on checking password policies and
expiration. Only the catalog view sys.sql_logins does.
Ref: sys.sql_logins - http://msdn2.microsoft.com/en-
us/library/ms174355.aspx
Question 55 - SQL Server 2005 - Security
You have just executed the command CREATE MASTER KEY
ENCRYPTION BY PASSWORD = 'P4ssw0rd!'; to create a
database master key on the AdventureWorks database and you
want to verify that the master key has been created, which query
will reveal the database master key? Submitted by Brian Kelley
Choose one of the answers below:
1. They are not really secure, they are only obfuscated. There are tools
that you can use to get at the code.
2. In SQL Server 2005 the encryption is total and complete and can
never be decoded.
3. The code is encrypted using a user-defined hash algorithm.
4. The code is encrypted using a SQL Server defined hash algorithm
with the details of the key used returned when the stored procedure etc
is created.
Answer:
1. They are not really secure, they are only obfuscated. There are tools
that you can use to get at the code.
The code itself is just obfuscated. However, you cannot edit the code,
the stored procedure or view would have to be dropped and re-created.
Using a DDL trigger that executes on object creation, you can tell when
it has been modified.
You can find the answer on page 311 of Beginning SQL Server 2005
for Developers: From Novice to Professional.
Ref: CREATE PROCEDURE - http://msdn2.microsoft.com/en-
us/library/ms187926(SQL.90).aspx
Question 57 - SQL Server 2005 - SMO,
RMO, AMO
In SQL Server 2005, SMO has replaced DMO as the
management object framework. SMO is developed with .NET.
Can you still call SMO objects from VBScript?
Choose one of the answers below:
1. Yes, but you would need to wrap your VBScript in a .NET wrapper.
2. No, you cannot use VBScript any longer.
3. Yes, there are COM wrappers around the .NET assemblies.
4. No, there is no way to access these objects from non-.NET enabled
code.
Answer:
3. Yes, there are COM wrappers around the .NET assemblies.
Yes, you can still call these objects from VBScript. You do not call the
.NET assemblys directly. Instead you would reference the .COM
wrappers that are placed around each assembly. There is a
SQLSMO.dll file that allows COM access.
Ref: SMO Overview - http://msdn2.microsoft.com/en-
us/library/ms162557.aspx
Question 58 - SQL Server 2005 - SMO,
RMO, AMO
In the new management object framework for SQL Server 2005,
there are new categories of classes: instance and utility classes.
Various functions and information has been moved around.
Which of the following are valid classes?
Choose one of the answers below:
1. Scripter
2. Generator
3. JobExec
4. DBBackup
Answer:
1. Scripter
The utility classes have been added to handle certain tasks. There are
Transfer classes, Backup and Restore classes, and the Scripter classes.
In the Instance classes, there are still the Server, Database, User, Table,
etc. classes. The other classes listed below are not valid.
Ref: SMO Classes - http://msdn2.microsoft.com/zh-
cn/library/ms199467.aspx
Scripter Class - http://msdn2.microsoft.com/en-
us/library/microsoft.sqlserver.management.smo.scripter.aspx
Question 59 - SQL Server 2005 - SMO,
RMO, AMO
You wish to build an application in VB.NET that will keep track of
and manage some of your SQL Server 2005 replication
configurations. Which namespace in SMO would you use?
Choose one of the answers below:
1. Microsoft.SqlServer.Management.Smo.Replication
2. Microsoft.SqlServer.Smo.Management.Replication
3. Microsoft.SqlServer.Smo.Replication.Management
4. You cannot do this using SMO.
Answer:
4. You cannot do this using SMO.
This is a bit of a trick question. SMO (System Management Objects) in
SQL Server 2005 replaces the DMO object framework in SQL Server
2000. However replication is not included in this framework. The
replication object framework has been moved to RMO (Replication
Management Objects).
Ref: Replication Management Objects -
http://msdn2.microsoft.com/en-us/library/ms148076.aspx
Question 60 - SQL Server 2005 - SMO,
RMO, AMO
What does this snippet of SMO code do?
this.Cursor = Cursors.WaitCursor;
if (DBCount > 0)
{
lblDB.Text = "&Database - " + DBCount + "
found. Select one from the following list:";
comboDB.Enabled = true;
}
else
lblDB.Text = "&Database";
CheckSystemDB.Enabled = true;
Choose one of the answers below:
1. Use the Event Viewer and select SSIS Logs in the left hand pane
below Application Logs, Security Logs, and System Logs.
2. You cannot access the Integration Services event logs in Event
Viewer.
3. In the Event Viewer, under the Application logs, set a filter for
"SSIS" as the source.
4. In the Event Viewer, under the Application logs, set a filter for
"SQLISService" as the source.
Answer:
4. In the Event Viewer, under the Application logs, set a filter for
"SQLISService" as the source.
You can view the Integration Services event logs by running the
Windows Event Viewer and setting a source filter on "MsDtsServer".
Ref: View Event Logs for Integration Services Service Using the Event
Viewer - http://msdn2.microsoft.com/en-us/library/ms137978.aspx
Question 63 - SQL Server 2005 - SSIS
In SQL Server 2005 Integration Services, what does the derived
column transformation do?
Choose one of the answers below:
1. In Process
2. Out of Process
3. Either
4. Neither
Answer:
3. Either
The answer is either. You can specify this with the
ExecuteOutOfProcess property.
Ref: ExecutePackageTaskClass.ExecuteOutOfProcess Property -
http://msdn2.microsoft.com/en-
us/library/microsoft.sqlserver.dts.tasks.executepackagetask.executepac
kagetaskclass.executeoutofprocess.aspx
Question 67 - SQL Server 2005 - SSIS
In SQL Server 2005, are SQL Server Integration Services able to
be clustered?
Choose one of the answers below:
1. Yes
2. No
Answer:
1. Yes
In SQL Server 2005, you can make the SSIS services clustered, either
in the same group as SQL Server or a separate group.
Ref: How to: Configure Integration Services on a Cluster -
http://msdn2.microsoft.com/en-us/library/ms345193.aspx
Making SSIS a Clustered Service
http://sqljunkies.com/WebLog/knight_reign/archive/2005/07/06/16015.
aspx.
Question 68 - SQL Server 2005 - SSIS
How can you execute a DTS package in SQL Server 2005
Integration Services using the local server, but loading the
package from a remote server?
Choose one of the answers below:
1. System::StartTime
2. System::ContainerStartTime
3. System::EventHandlerStartTime
4. You can't do this
Answer:
2. System::ContainerStartTime
Answer: #2. Explanation: System::ContainerStartTime contains the
time that the container that raised the event began to execute. When a
data-flow task executes the container in question is a TaskHost
container. There is more information here:
http://www.sqljunkies.com/WebLog/knight_reign/archive/2005/06/07/
15755.aspx and here:
http://blogs.conchango.com/jamiethomson/archive/2004/12/13/445.asp
x
Question 70 - SQL Server 2005 - SSIS
SSIS can store the multi-row results of a SQL query issued from
an Execute SQL Task in a variable. What must the datatype of
that variable be? Submitted by Jamie Thomson
Choose one of the answers below:
1. XML
2. String
3. Object
4. Resultset
Answer:
3. Object
Early versions of BOL stated that this should be stored in a String
variable. This is erroneous and has been corrected. There are no such
things as XML variables or ResultSet variables in SSIS.
Ref: Execute SQL Task - http://msdn2.microsoft.com/en-
us/library/ms141003.aspx
Question 71 - SQL Server 2005 - SSIS
Which of the following is true? Submitted by Jamie Thomson.
Choose one of the answers below:
1. Audit
2. Aggregate
3. Conditional Split
4. Derived Column
Answer:
2. Aggregate
The Aggregate transformation is asynchronous, which means it does
not consume and publish data row by row. Instead it consumes the
whole rowset, performs its groupings and aggregations, and then
publishes the results.
Ref: Aggregate Transformation = http://msdn2.microsoft.com/en-
us/library/ms191497.aspx
Audit Transformation - http://msdn2.microsoft.com/en-
us/library/ms141150.aspx
Conditional Split - http://msdn2.microsoft.com/en-
us/library/ms137886.aspx
Derived Column Transformation - http://msdn2.microsoft.com/en-
us/library/ms141069.aspx
Question 73 - SQL Server 2005 - SSIS
Which component enables you to select the first N rows that
pass through your data-flow and discard the rest?
Choose one of the answers below:
1. Script
2. Conditional Split
3. Data Conversion
4. Pivot
Answer:
1. Script
The script component will allow you to selec the first N rows and
discard the rest.
Ref: Script comonent - http://msdn2.microsoft.com/en-
us/library/ms137640.aspx
Question 74 - SQL Server 2005 - SSIS
Suppose you have a script component with 2 synchronous
outputs in the same ExclusionGroup called "MyOutput1" &
"MyOutput2". Which of the following 2 methods are generated
for you automatically?
Choose one of the answers below:
1. SQL Server
2. XML configuration file
3. Parent package variable
4. Environment variable
Answer:
3. Parent package variable
It is actually Parent Package variable configuration for which the parent
package has to execute to update parent package variable before it can
be used in the child package configuration.
Ref: How to: Use Values of Parent Variables in Child Packages -
http://msdn2.microsoft.com/en-us/library/ms345179.aspx
Question 76 - SQL Server 2005 - SSIS
What method do you have to call in an asynchronous script
component to allow you to add rows to an output called "Output
0"? Submitted by Jamie Thomson
Choose one of the answers below:
1. Output0.AddRow()
2. Output_0.Addrow()
3. Output0Buffer.AddRow()
4. Output0Buffer.DirectRowToOutput0
Answer:
3. Output0Buffer.AddRow()
3 is the correct syntax for this. 1 & 2 are invalid syntax. The
DirectRowTo() syntax in 4 is used in synchronous script components.
Ref: Creating an Asynchronous Transformation with the Script
Component - http://msdn2.microsoft.com/en-us/library/ms136133.aspx
Question 77 - SQL Server 2005 - SSIS
Which of the following statements most accurately describes the
difference between synchronous and asynchronous script
components? Submitted by Jamie Thomson
Choose one of the answers below:
1. Dts.Variables("foovar").value
2. Dts.Variables.foovar
3. Dts.Variables("user::foovar").value
4. Me.Variables.foovar
Answer:
4. Me.Variables.foovar
The correct reference uses the self referencing object "Me".
Ref: Comparing the Script Task and the Script Component -
http://msdn2.microsoft.com/en-us/library/ms136031.aspx
Question 79 - SQL Server 2005 - SSIS
In which languages can SQL Server 2005 Integration Services
script components be built? Submitted by Jamie Thomson
Choose one of the answers below:
1. C#
2. VB.NET
3. C# & VB.Net
4. Any .Net language
Answer:
2. VB.NET
The script component relies on Visual Studio for Applications (VSA)
which currently only supports VB.Net.
Ref: Extending the Data Flow with the Script Component -
http://msdn2.microsoft.com/en-us/library/ms136118.aspx
Integration Services Programming (see note at bottom of language
section) - http://msdn2.microsoft.com/zh-tw/library/ms136025.aspx
Question 80 - SQL Server 2005 - SSIS
Which of the following is the signature of the method called to
process all the incoming rows in a script component? Submitted
by Jamie Thomson
Choose one of the answers below:
1. Input0_ProcessInputRow()
2. Input0_ProcessInputRow(ByVal Row As IDTSInput90)
3. Input0_ProcessInputRow(ByVal Row As Input0Buffer)
4. Input0_ProcessInputRow(ByVal Row As InputBuffer)
Answer:
3. Input0_ProcessInputRow(ByVal Row As Input0Buffer)
3 gives the correct syntax for the script component. The method
_ProcessInputRow(...) takes one parameter which is the row currently
being processed. The type of that parameter is the type of a class
generated at design-time that is named by taking the name of the input
(in this case "Input 0") removing whitespace, and appending the word
"Buffer".
Hence, in this case because we have an input called "Input 0" or
"Input0" (which we know we have because of the name of the method),
the type of the parameter is "Input0Buffer".
And just to re-iterate the point, the type of the parameter (excepting the
word "Buffer") will be the same as the begining of the method name up
to the underscore.
Ref: Extending the Data Flow with the Script Component -
http://msdn2.microsoft.com/en-us/library/ms136118.aspx
Question 81 - SQL Server 2005 - SSIS
Which SSIS pipeline datatype should you use to store datetime
values with days, hours and seconds specified in them?
Submitted by Jamie Thomson
Choose one of the answers below:
1. DT_TIME
2. DT_DATE
3. DT_DBTIMESTAMP
4. DT_DBDATE
Answer:
3. DT_DBTIMESTAMP
DT_TIME only stored hours minutes and seconds. DT_DBDATE only
stores years, months and days. DT_DATE and DT_DBTIMESTAMP
can both store years down to milliseconds but they have different
internal representations and DT_DBTIMESTAMP is more reliable than
DT_DATE. More info here:
http://blogs.conchango.com/jamiethomson/archive/2005/11/15/2399.as
px
- http://msdn2.microsoft.com/en-us/library/ms141036.aspx
Question 82 - SQL Server 2005 - SSIS
Where should you place your SSIS package templates if you
want them made available to you as a basis for new packages?
Submitted by Jamie Thomson
Choose one of the answers below:
1. XML File
2. Text file
3. Registry Entry
4. Environment variable
Answer:
2. Text file
SSIS does not allow configurations to be formatted in free format text
files. There is some more info here on using environment variables and
XML configuration files together:
http://blogs.conchango.com/jamiethomson/archive/2005/11/02/2342.as
px
Package Configurations - http://msdn2.microsoft.com/en-
us/library/ms141682.aspx
Question 84 - SQL Server 2005 - TSQL
SQL Server 2005 has a number of T-SQL enhancements, including the
ability to generate delimited lists. If I want to return the following
numeric values:
1;2;3;4;5;
1. 1
2. 3
3. 2
4. Limited to 128
Answer:
2. 3
A recursive query is made up of 3 SELECT statements. There will be
two internal SELECT statements joined by a UNION ALL. The first
statement is called the anchor member and it forms the basic result set.
The second statement is called the recursive member and this is where
the CTE references itself. The recursive member forms the next part of
the result set using the anchor member as input. The recursive member
is called repeatedly until no more rows are returned (called the exit
condition). There is a third outer SELECT that is the one that returns
the data to the caller.
Ref: Recursive Queries Using Common Table Expressions -
http://msdn2.microsoft.com/en-us/library/ms186243.aspx
Common Table Expressions - http://www.simple-talk.com/sql/sql-
server-2005/sql-server-2005-common-table-expressions/
Question 89 - SQL Server 2005 - TSQL
You have an extremely long (> 100 lines) stored procedure that
has given you problems in the past because of recompilations
due to changing conditions on the server. Which of the following
enhancements in SQL Server 2005 should provide a
performance benefit to your system?
Choose one of the answers below:
1. Snapshot Isolation
2. DDL Triggers
3. Common Table Expressions
4. Statement Level Recompile
Answer:
4. Statement Level Recompile
The Statement Level Recompilation feature, which allows the
recompilation of a portion of a query plan instead of the entire thing
can improve performance in this case.
Ref: Batch Compilation, Recompilation, and Plan Caching Issues in
SQL Server 2005 -
http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
Question 90 - SQL Server 2005 - TSQL
What would this match in a regular expression?
^(com|net|edu|org)
Choose one of the answers below:
1. "sqlservercentral.com"
2. anything containing "com" but not "net", "edu", or "org"
3. "edu" or "com" or "net" or "org"
4. a string that contains all four domains.
Answer:
3. "edu" or "com" or "net" or "org"
The parens and the | indicate an OR matching of any of the items listed
between the |. In this case, without anything before or after, this
expression would only match "com" by itself or any of the others by
themselves.
Ref: Regular Expressions Quick Start - http://www.regular-
expressions.info/quickstart.html
Question 91 - SQL Server 2005 - TSQL
What will be the output of this piece of T-SQL code? Submitted
by Frederik Vandeputte
BEGIN TRY
DROP master.sys.objects
END TRY
BEGIN CATCH
SELECT 'The following error occured: ' +
ERROR_MESSAGE()
END CATCH
Choose one of the answers below:
1.
SELECT sxi.name "Index", so.name "Table"
FROM sys.xml_indexes sxi
INNER JOIN sys.objects so
ON (so.object_id = sxi.object_id)
WHERE using_xml_index_id IS NULL;
2.
SELECT sxi.name "Index", so.name "Table"
FROM sysindexes sxi
INNER JOIN sys.objects so
ON (so.object_id = sxi.object_id)
WHERE using_xml_index_id IS NULL;
3.
SELECT sxi.name "Index", so.name "Table"
FROM sysxmlindexes sxi
INNER JOIN sys.objects so
ON (so.object_id = sxi.object_id)
WHERE using_xml_index_id IS NULL;
4.
SELECT sxi.name "Index", so.name "Table"
FROM INFORMATION_SCHEMA.INDEXES
WHERE using_xml_index_id IS NULL;
Answer:
1.
SELECT sxi.name "Index", so.name "Table"
FROM sys.xml_indexes sxi
INNER JOIN sys.objects so
ON (so.object_id = sxi.object_id)
WHERE using_xml_index_id IS NULL;
The first query will actually scan the xml_indexes table and join it to
sysobjects to find a list of tables that have XML indexes built on them.
Ref: sys.xml_indexes - http://msdn2.microsoft.com/en-
us/library/ms176003.aspx
Indexes on xml Data Type Columns - http://msdn2.microsoft.com/en-
us/library/ms191497.aspx
Question 94 - SQL Server 2005 - XML
Which of the following queries will preserve the whitespace in an
XML document?
Choose one of the answers below:
Data b
1. 0
2. 1
3. An error as there is no assembly in the default SQL CLR that will
handle the .exist method.
4. False because database mirroring is turned off by default.
Answer:
2. 1
This will return a one row, one column result set with a 1 as this
particular class exists in the XML document. This allows you to query
the native XML store in SQL Server to find out if a particular element
exists in the document before you query for it's attributes or child
elements.
Ref: exist() Method - http://msdn2.microsoft.com/en-
us/library/ms189869.aspx
Question 96 - SQL Server 2005 - XML
What is a Primary XML Index in SQL Server 2005?
Choose one of the answers below:
1. Yes, the reference will still work, but will not see the new changes
until you recompile it.
2. Of course, if you change the assembly, you need to rebind the
function to the assembly or your code will all fail.
3. No, it will automatically work.
Answer:
1. Yes, the reference will still work, but will not see the new changes
until you recompile it.
You do not need to recompile the function for it to work. The reference
to the assembly will still work, but will call the old assembly. To see
the new changes, you would need to recompile your function.
Ref: Altering an Assembly - http://msdn2.microsoft.com/en-
us/library/ms345098.aspx
Implement User-defined Functions in SQL Server 2005 with Managed
Code -
http://www.developer.com/net/csharp/article.php/10918_3399881_2
Question 98 - SQL Server Development
You wish to store XML documents in SQL Server 2005. What is
the best data type to use and still have the data available for
querying?
Choose one of the answers below:
1. varchar(max)
2. varbinary(max)
3. xml
Answer:
3. xml
The best option is the XML data type. This datatype shreds XML and
stores it in an internal binary format for easy querying.
Ref: XML Options in Microsoft SQL Server 2005 -
http://msdn.microsoft.com/en-us/dnsql90/html/sql2k5xmloptions.asp
XML data type - http://msdn2.microsoft.com/en-
us/library/ms189887.aspx
Question 99 - T-SQL
What could be the output of this query?
Declare @intVal1 Int,
@intVal2 Int,
@Result Numeric(9,2)
Select @intVal1 = 10, @intVal2 = 3
Select @Result = @intVal1/@intVal2
print @Result
Choose one of the answers below:
1. 3.30
2. 3.33
3. 3.00
4. 4.00
5. Error
Answer:
3. 3.00
The data type precedence rules defined that when integer value is
divided by an integer value, the result of that process will be an integer.
Hence your result will be 3.00
Question 100 - Tools
You want to script the execution of an Integration Services
package from the command line for use from a Unix scheduler.
What utility would you use?
Choose one of the answers below:
1. ssisexec.exe
2. dtsexec.exe
3. dtexec.exe
4. dtutil.exe
Answer:
3. dtexec.exe
The dtexec.exe utility is used to configure and execute Integration
Services packages from the command line.
Ref: dtexec.exe - http://msdn2.microsoft.com/en-
us/library/ms162810.aspx