单项选择题
You are creating a stored procedure that will delete data from the Contact table in a SQL Server 2005 database. The stored procedure includes the following Transact-SQL statement to handle any errors that occur.
BEGIN TRY
BEGIN TRANSACTION
DELETE FROM Person.Contact
WHERE ContactID = @ContactID
COMMIT TRANSACTION
END TRY
BEGIN CATCH
DECLARE @ErrorMessage nvarchar(2000) DECLARE @ErrorSeverity int DECLARE @ErrorState int SELECT @ErrorMessage = ERROR MESSAGE(),@ErrorSeverity=ERROR SEVERITY(),@ErrorState = ERROR STATE() RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState) END CATCH;
You test the stored procedure and discover that it leaves open transactions.
You need to modify the stored procedure so that it properly handles the open transactions.
What should you do?()
A.Add a COMMIT TRANSACTION command to the CATCH block.
B.Remove the COMMIT TRANSACTION command from the TRY block.
C.Add a ROLLBACK TRANSACTION command to the CATCH block.
D.Add a ROLLBACK TRANSACTION command to the TRY block.
相关考题
-
单项选择题
You work for a company that sells books. You are creating a report for a SQL Server 2005 database. The report will list sales representatives and their total sales for the current month. The report must include only those sales representatives who met their sales quota for the current month. The monthly sales quota is $2,000. The date parameters are passed in variables named @FromDate and @ToDate. You need to create the report so that it meets these requirements. Which SQL query should you use?()
A.SELECT s.AgentName,SUM(ISNULL(o.OrderTotal,0.00))AS SumOrderTotalFROM SalesAgents JOIN OrderHeader o ON s.AgentID=o.AgentIDWHERE o.OrderDate BETWEEN @FromDate AND @ToDateGROUP BY s.AgentName
B.SELECT s.AgentName, SUM(ISNULL (o.OrderTotal,0.00))AS SumOrderTotalFROM SalesAgent s JOIN OrderHeader o ON s.AgentID = o.AgentIDWHERE o.OrderDate BETWEEN @FromDate AND @ToDate AND o.OrderTotal >= 2000GROUP BY s.AgentName
C.SELECT s.AgentName, SUM(ISNULL (o.OrderTotal,0.00)) AS SumOrderTotalFROM SalesAgent s JOIN OrderHeader o ON s.AgentID=o.AgentID WHERE o.OrderDate BETWEEN @FromDate AND@ToDateGROUP BY s.AgentNameHAVING SUM(o.OrderTotal)>=2000
D.SELECT s.AgentName, SUM(ISNULL(o.OrderTotal,0.00)) AS SumOrderTotalFROM SalesAgent s JOIN OrderHeader o ON s.AgentID=o.AgentIDWHERE o.ordertotal=2000 AND o.OrderDate BETWEEN @FromDate AND @ToDateGROUP BY s.AgentNameHAVING SUM(o.OrderTotal) >= 2000 -
单项选择题
You work in Dublin at the main office of TestKing.com. You are responsible for managing a SQL Server 2005 database. The sales department wants a report that compares customer activity in the previous quarter between the main office in Dublin and the branch office in Buenos Aires. They want the data sorted by surname and first name.You restore a recent backup of the Buenos Aires database onto your server. You write queries to build the report, ordering the data by the Surname and FirstName columns. You review the data and notice that the customer list from the Buenos Aires database is sorted differently. The sales department needs the revised data within 15 minutes for a presentation. You need to implement the fastest possible solution that ensures that the data from both databases is sorted identically. What should you do?()
A.Use the Copy Database Wizard to copy the data in the Buenos Aires database to a new database with the same collation as the Dublin database.
B.Use the SQL Server Import and Export Wizard to copy the data from the Buenos Airesdatabase into new tables, specifying the same collation as the Dublin database.
C.Modify the format file to specify the same collation as the Dublin database. Import the table again.
D.Modify the query on the Buenos Aires database to use the COLLATE setting in the ORDER BY clause. In the query, specify the same collation as the Dublin database. -
单项选择题
你需要在SQLServer2005数据库中创建一个连接客户表与订单表的视图。同时要确保底层数据表方案的更改不会影响到视图。你想要以可能的最小开销量达成此目标,你要怎样做?()
A.在数据表中创建CHECK约束
B.创建一个DDL触发器,若改动对视图中的列产生了影响,它将回滚到更改之前的数据表
C.创建视图时指定WITH SCHEMABINDING 选项
D.创建视图时指定WITH CHECK选项
