This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Distributed Queries”.
1. What is the syntax for using linked server stored procedure in SQL Server?
a)
sp_linkedserver [ @server= ] 'server' [ , [ @srvproduct= ] 'product_name' ] [ , [ @provider= ] 'provider_name' ] [ , [ @datasrc= ] 'data_source' ] [ , [ @location= ] 'location' ] [ , [ @provstr= ] 'provider_string' ] [ , [ @catalog= ] 'catalog' ]
b)
sp_addlinked [ @server= ] 'server' [ , [ @srvproduct= ] 'product_name' ] [ , [ @provider= ] 'provider_name' ] [ , [ @datasrc= ] 'data_source' ] [ , [ @location= ] 'location' ] [ , [ @provstr= ] 'provider_string' ] [ , [ @catalog= ] 'catalog' ]
c)
sp_addlinkedserver [ @server= ] 'server' [ , [ @srvproduct= ] 'product_name' ] [ , [ @provider= ] 'provider_name' ] [ , [ @datasrc= ] 'data_source' ] [ , [ @location= ] 'location' ] [ , [ @provstr= ] 'provider_string' ] [ , [ @catalog= ] 'catalog' ]
d)
sp_addlinkedser [ @server= ] 'server' [ , [ @srvproduct= ] 'product_name' ] [ , [ @provider= ] 'provider_name' ] [ , [ @datasrc= ] 'data_source' ] [ , [ @location= ] 'location' ] [ , [ @provstr= ] 'provider_string' ] [ , [ @catalog= ] 'catalog' ]
Explanation: After a linked server is created by using sp_addlinkedserver, distributed queries can be run against this server.
2. Point out the correct statement.
a) To access a mirrored database, a connection string must contain the database name
b) When the linked server is defined against an instance of SQL Server, catalog refers to the default database to which the linked server is mapped
c) [ @location= ] ‘location’ is the location of the database as interpreted by the OLE DB provider in sp_addlinkedserver
d) All of the mentioned
View Answer
Explanation: Location parameter is passed as the DBPROP_INIT_LOCATION property to initialize the OLE DB provider.
3. sp_addlinkedserver command creates a distributed server entry called _________ in the following code.
sp_addlinkedserver @server = "Northwinds", @srvproduct = "Access 97", @Provider = "Microsoft.Jet.OLEDB.3.51", @datasrc = "c:\brian\writing\sqlservermag\nov98\nwind.mdb"
a) Access 97
b) Microsoft.Jet.OLEDB.3.51
c) nwind
d) Northwinds
View Answer
Explanation: The command uses the Microsoft.Jet.OLEDB.3.51 OLE DB provider linking to an Access database located at c:\brian\writing\sqlservermag\nov98\nwind.mdb.
4. Which of the following command tells that all local users are logged in as “sa” in the following code?
EXEC sp_addlinkedsrvlogin @rmtsrvname = "Northwinds", @useself = "false", @locallogin = "sa", @rmtuser = "Admin", @rmtpassword = NULL
a) sp_addlinkedsrv
b) sp_addlinkedserver
c) sp_addlinkedsrvlogin
d) none of the mentioned
View Answer
Explanation: sp_addlinkedsrvlogin creates or updates a mapping between a login on the local instance of SQL Server and a security account on a remote server.
5. Point out the wrong statement.
a) SQL Server cannot use execution strategies that involve using the procedures of the Table provider to evaluate predicates
b) For a distributed query, the comparison semantics for all character data is defined by the character se
c) SQL Server can delegate comparisons and ORDER BY operations on character columns to a provide
d) None of the mentioned
View Answer
Explanation: SQL Server can use execution strategies that involve using the indexes of the Index provider to evaluate predicates and perform sorting operations against remote tables. To enable indexed access against a provider, set the IndexAsAccessPath provider option.
6. Which of the following function mainly used for bulk load data is referenced in the following code?
SELECT RemoteOrders.* FROM OpenRowset("Microsoft.Jet.OLEDB.3.51", "c:\brian\writing\sqlservermag\nov98\nwind.mdb"; "admin"; , "select * from orders") RemoteOrders LEFT JOIN MasterOrders ON RemoteOrders.OrderId = MasterOrders.OrderId WHERE MasterOrders.OrderID = NULL
a) OpenRowset
b) Microsoft.Jet.OLEDB
c) admin
d) All of the mentioned
View Answer
Explanation: The OPENROWSET function can be referenced in the FROM clause of a query as if it were a table name.
7. Which of the following SQL syntax elements is dictated by the SQL dialect levels?
a) LIKE support
b) Parameter marker support
c) Nested query support
d) None of the mentioned
View Answer
Explanation: System administrator should set the NestedQueries provider option to indicate to SQL Server that the provider supports nested queries.
8. Which of the following function will be preferred for faster execution in following code?
SELECT RemoteOrders.* FROM ________(Northwinds, "select * from orders") RemoteOrders LEFT JOIN MasterOrders ON RemoteOrders.OrderId = MasterOrders.OrderId WHERE MasterOrders.OrderID = NULL
a) OpenRow
b) OpenSQL
c) OpenQuery
d) All of the mentioned
View Answer
Explanation: OpenQuery runs a little faster because you’re using the connection information that you already supplied using sp_addlinkedserver.
9. Which of the following query combines data from more than one SQL Server instance?
a)
USE SCRATCH GO SELECT TOP 1000 * FROM REMOTE.Scratch.dbo.Table1 T1 INNER JOIN REMOTE.Scratch.dbo.Table2 T2 ON T1.ID = T2.ID
b)
USE SCRATCH GO SELECT * FROM dbo.Table1 T1 INNER JOIN REMOTE.Scratch.dbo.Table2 T2 ON T1.ID = T2.ID WHERE T1.GUIDSTR < '001'
c)
USE SCRATCH GO SELECT TOP 500 * FROM REMOTE.Scratch.dbo.Table1 T1 OUTER JOIN REMOTE.Scratch.dbo.Table2 T2 ON T1.ID = T2.ID
d) None of the mentioned
View Answer
Explanation: Table1 from LOCAL is being joined to Table2 on REMOTE, with a restriction being placed on Table 1’s GUIDSTR column by the WHERE clause.
10. The easiest way to start is to create a linked server ‘localhost’ by using _____________
a) sp_addlinkedserv ‘localhost’
b) sp_addlinkedsrvlogin ‘localhost’
c) sp_addlinkedserverlogin ‘localhost’
d) sp_addlinkedserver ‘localhost’
View Answer
Explanation: “localhost” linked server is created when you reference objects using a four-part name in the form linkedserver.catalog.schema.object.
Sanfoundry Global Education & Learning Series – SQL Server.
To practice all areas of SQL Server, here is complete set of 1000+ Multiple Choice Questions and Answers.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Apply for Programming Internship
- Check Information Technology Books
- Practice Programming MCQs
- Check SQL Server Books