You are creating a stored procedure that will delete data fr

题目
单选题
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.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

You delete content from a file named Speed.doc that is stored in the C:\Data folder. You edit 20 files in this folder over the next two days. You need to restore the version of the file that had the correct data. You also need to ensure that the other fiels in the folder remain unaffected.What should you do?()

A.A

B.B

C.C

D.D


参考答案:A

第2题:

The accounting manager wants you to create a form that when queried will display a calculated total of year-to-date actual expenditures for the found code entered. The values needed to generate this summary data are stored in multiple tables. Which data source type can you assign to the data block for this form without having the DBA create a database object?()

  • A、database table 
  • B、transactional trigger 
  • C、stored procedure 
  • D、FROM clause query 
  • E、client-side procedure

正确答案:D

第3题:

You are the administrator of a SQL Server 2000 computer. The server contains confidential information about contracts on which your company has placed bids.

Company policy requires that bid information be removed permanently from the database one year after the bid closes. You need to comply with this policy and minimize server overhead.

What should you do?

A.Create a Data Transformation Services (DTS) package to remove bids that have a closing data older than one year.

B.Create a trigger to delete any bids that have a closing data older than one year. Bind the trigger to the bids table for all INSERT, UPDATE, and DELETE events.

C.Create a stored procedure to delete any bids that have a closing data order than one year. Use SQL server agent to schedule the stored procedure to run every night.

D.Create a view that contains a WHERE clause to exclude bids that have a closing date older than one year.


正确答案:C
解析:Explanation:Thisscenariorequiresustoremoveoldinformationonaregularbasis.Firstwecreateastoredprocedurewhichremovesallrowswherethebidinformationdateisolderthanthecurrentdateminusoneyear.Thenweschedulethisproceduretoruneveryday.Wewouldthenbesuretoneverhaveanyrowsolderthanayearinthetable.Note:Storedproceduresalsoimproveperformanceasthestoredprocedureiscachedafteritisrun.ThisresultsinareductionofphysicalI/O.WecanfurtherreduceServeroverheadbyschedulingthestoredproceduretorunduringoff-peakhours.IncorrectAnswers:A:ADataTransformationServices(DTS)packageprovidesasetoftoolsthatallowsustoextract,transform,andconsolidatedatastoredinavarietyofformatsandindifferentlocationsintosingleormultipledestinationssupportedbyDTSconnectivity.Thissolutionisinappropriate,asthedataexistsontheserverandnotinnumerouslocationsandwouldthusbecorrectlyformattedforuseonaninstanceSQLServer2000.B:TriggersareaspecialtypeofstoredprocedurethatexecutesautomaticallywhenanUPDATE,INSERT,orDELETEstatementisrunagainstatableorview.Inthisscenariohowever,thedatestampofthedatainthedatabasemustbecheckedandthedatadeletedoneyearafterthebidhasclosed.Thiscannotbeaccomplishedthroughtheuseofconstraintsortriggers.D:Creatingaviewthatexcludesthebidsthathaveaclosingdateolderthanoneyeardoesnotaddressthecompanypolicythatrequiresthatbidinformationberemovedpermanentlyfromthedatabaseoneyearafterthebidcloses.Thisdatawillstillexistinthebasetables.

第4题:

You are designing the loan application process for the customer terminals. You need to design a Transact-SQL stored procedure that fulfills the business and technical requirements. Which type of Transact-SQL stored procedure should you use?()

  • A、one that uses an internal SQL Server Web service endpoint
  • B、one that runs a SQL Server Integration Services (SSIS) package
  • C、one that uses Service Broker
  • D、one that runs a user-defined function

正确答案:C

第5题:

You work in a company which uses SQL Server 2008. You are the administrator of the company database. Now you are in charge of a remote SQL Server 2008 instance. You notice that the application has a poor performance. On the remote SQL Server instance, you capture a workload of the remote instance to a trace table by using SQL Profiler. Now you have to use the Database Engine Tuning Advisor to analyze the workload of the remote SQL Server instance on a local SQL Server instance.  So what action should you perform to achieve this goal?()

  • A、You should recapture the workload by using the data collector.
  • B、You should enable the XP_MSVER stored procedure on the local server.
  • C、You should enable the XP_MSVER stored procedure on the remote server
  • D、You should recapture the workload to a trace file by using SQL Profiler.

正确答案:D

第6题:

Consider the Mysql Enterprise Audit plugin. A CSV file called data.csv has 100 rows of data. The stored procedure prepare_db ( ) has 10 auditable statements. You run the following statements in the mydb database: Mysql> CALL prepare_db ( ); Mysql> LOAD DATA INFILE '/tmp/data.cav' INTO TABLE mytable; Mysql> SHOW TABLES; How many events are added to the audit log as a result of the preceding statements?()

  • A、12; only top-level statements and stored procedure events are logged
  • B、111; top-level statements and all lower-level statements are logged
  • C、3; only the top-level statements are logged
  • D、102; top-level statements are logged, but LOAD DATA INFILE is logged as a separate event

正确答案:C

第7题:

You need to cleanse and standardize the data on potential survey participants prior to inserting it into the staging database. What should you do?()

  • A、Import the data into a staging table by using the OPENROWSET BULK statement. Execute a Transact-SQL stored procedure to cleanse the data and to insert the data into the database.
  • B、Import the data into a staging table by using the BULK INSERT statement. Execute a Transact-SQL stored procedure to cleanse the data and to insert the data into the database.
  • C、Create a SQL Server Integration Services (SSIS) package to import, standardize, and cleanse the data.
  • D、Create a CLR stored procedure to import the data into a staging table, to cleanse and standardize the data, and to insert the data into the database.

正确答案:C

第8题:

You are the administrator of a SQL Server 2000 database. Using the default options configures the database. You drop indexes to facilitate a large import of data, and rebuild them after the import is complete.

Users report that response times from a stored procedure have become slower. In the stored procedure, you examine the following code.

CREATE PROCEDURE GetCustomer

( @CustomerID Int )

AS

SELECT FirstName, LastName, Address1, Address2, City,

State, Zip, MAX(PurchaseDate) AS LastPurchase

FROM Customers C

JOIN Addresses A ON A.AddressID = C.AddressID

JOIN Purchases P ON P.CustomerID = C.CustomerID

WHERE C.CustomerID = @CustomerID

GROUP BY FirstName, LastName, Address1, Address2, City, State, Zip

You want to improve the performance of the procedure by using the least amount of administrative effort. What should you do?

A.Recompile the stored procedure.

B.Update the database statistics.

C.Check the consistency of the database and repair errors.

D.Create a view and modify the stored procedure to use the view.


正确答案:A
解析:Explanation:ByrecompilingthestoredprocedureSQLServerwillcreateanewexecutionplanforthestatementsintheprocedure.SQLServerwilldetectthatstatisticsarenotuptodateanditwillautomaticallyrecreatethestatisticsduringthisprocess.Theexecutionplanwillbeoptimizedforthecurrentdistributionofdatainthetables.Note:Storedprocedurescanbeusedtoimprovedatabasequeryperformance.IftheseSQLstatementsandconditionallogicarewrittenintoastoredprocedure,theybecomepartofasingleexecutionplanthatiscachedontheserver.Whenthedatabaseischangedbytheadditionofnewindexesorwhendatainindexedcolumnsarechanged,theoriginalqueryplansandstoredproceduresusedtoaccessthetablesshouldbereoptimizedbyrecompilingthem.ThisoptimizationhappensautomaticallythefirsttimeastoredprocedureisrunafterSQLServer2000isrestarted.Italsooccursifanunderlyingtableusedbythestoredprocedurechanges.Butifanewindexisaddedfromwhichthestoredproceduremightbenefit,optimizationdoesnotautomaticallyoccuruntilthenexttimethestoredprocedureisrunafterSQLServerisrestarted.Thestoredprocedurecanbemanuallyrecompiledbyusingthesp_recompilesystemstoredprocedure.Thisforcesthestoredproceduretoberecompiledthenexttimeitisrun.IncorrectAnswers:B:SQLServerdetectswhetherstatisticsarenotup-to-date,andbydefaultitautomaticallyupdatesthemduringqueryoptimization.Byrecompilingthequerythestatisticswillautomaticallybeupdated.Note:SQLServerkeepsstatisticsaboutthedistributionofthekeyvaluesineachindexandusesthesestatisticstodeterminewhichindex(es)touseinqueryprocessing.Queryoptimizationdependsontheaccuracyofthedistributionsteps.Ifthereissignificantchangeinthekeyvaluesintheindex,orifalargeamountofdatainanindexedcolumnhasbeenadded,changed,orremoved,orthetablehasbeentruncatedandthenrepopulated,UPDATESTATISTICSshouldbererun.C:Consistencyofadatabaseismaintainedthroughtheuseofconstraintsandtriggers.Thesemechanismsareusedtoensurethatthedatabaseremainsconsistentbycontrollingthetypeofdatathatcanbeinsertedintoacolumn,throughreferentialintegritychecks,andthroughcascadingreferentialconstraints.D:Aviewisavirtualtablethatcanbeusedtorestrictusersaccesstothebasetable,ortojoinvariousbasetablessothattheyappearasasingletable.However,creatingaviewthatthestoredproceduremustaccesswouldrequirethecreationofindexesontheviewandwillhavetobeupdatedwhenthebasetablesareupdates.Thiswouldrequiregreateradministrativeeffort.

第9题:

You work in a company which uses SQL Server 2008. You are the administrator of the company database. Now you are in charge of a SQL Server 2008 instance. There is a stored procedure. The stored procedure implements a database maintenance process. A SQL Server Agent job should be created to that runs the stored procedure. Besides this, you must make sure that after it is completed successfully, the job is removed.  What should you do? ()

  • A、You should create a job which is assigned to the Database Maintenance category
  • B、You should create an Alert which will run another to delete the maintenance job.
  • C、You should create a job. You schedule the job to run only once.
  • D、You should create a job. The job uses the Automatically delete job option

正确答案:D

第10题:

You work in a company which is named Wiikigo Corp. The company uses SQL Server 2008. You are the administrator of the company database. Now you are in charge of a SQL Server 2008 instance. There is a database named DB1 in the instance. DB1 has a table which is named Table01 and a stored procedure named Procedure01. Procedure01 choose data from Table01 by using a sp_executesql Transact-SQL statement. You company security rules forbid users to access tables directly in any database. Look at the exception below: "Msg 229, Level 14, State 5, Line 1 The SELECT permission was denied on the object 'Table01', database 'DB1', schema 'dbo'." The exception is raised when Procedure01 is executed by users. You must make sure that e user can successfully execute Procedure1 complying with the company rules. So what action should you perform to achieve this goal?()  

  • A、You should execute the GRANT SELECT ON dbo.Table01 TO User1 Transact-SQL statement. 
  • B、You should execute the GRANT EXECUTE ON dbo.Procedure1 TO User1 Transact-SQL statement. 
  • C、You should alter Procedure01 and add the WITH EXECUTE AS OWNER option to its header 
  • D、You should alter Procedure01 and add the EXECUTE AS USER = 'dbo' option immediately before the call to the sp_executesql stored procedure.

正确答案:C

更多相关问题