top of page

Fixing the stored procedure

You have a memory-optimized table named Customer. The table is accessed by a stored procedure named ManageCustomer. The database was created in Microsoft SQL Server 2014. A backup and restore operation was used to move the database to SQL Server 2016.

You have performance issues with the stored procedure. You need to resolve the performance issues and ensure the table statistics are updated automatically.

Which three Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact- SQL segments to the answer area and arrange them in the correct order.

 

Answer Given:

Step 1: ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL

Sets certain database behaviors to be compatible with the specified version of SQL Server. Syntax: ALTER DATABASE database_name - SET COMPATIBILITY_LEVEL = { 150 | 140 | 130 | 120 | 110 | 100 | 90 }

Step 2: UPDATE STATISTICS Customers UPDATE STATISTICS updates query optimization statistics on a table or indexed view.

Step 3: EXEC sp_recompile N' 'Manage_customer' sp_recompile causes stored procedures, triggers, and user-defined functions to be recompiled the next time that they are run. It does this by dropping the existing plan from the procedure cache forcing a new plan to be created the next time that the procedure or trigger is run

References: https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level https://docs.microsoft.com/en-us/sql/t-sql/statements/update-statistics-transact-sql


aboutME

I am John Fan Zhang, a data analyst and finance researcher. I hold a PhD in finance, CFA charter and full membership of CFA New Zealand Society. I have fifteen-year experience in corporate investment and eight-year experience in advanced data analysis. My research focuses on the effect of social psychology (culture) on financial decisions. Finance research involves heaps of data analyses that lead me to the data field. I am a Microsoft Certified Solutions Expert (MCSE): Data Management and Analytics (Excel, Power BI, and SQL). Aside from Excel, Power BI and SQL, I am also familiar with econometric tools such as Stata, Eviews, and MATLAB. I use OX and Python for programming. I am an active data community event participant, volunteer, speaker, moderator, program reviewer, including PASS Marathon 2020, Global AI BootCamp Auckland 2019, SQL Saturday Auckland (2017, 2018, 2019), and Definity Conference (2018, 2019, 2020, Auckland, New Zealand).

Auckland, New Zealand

  • Google Site
  • Twitter
  • LinkedIn

©2016 BY JOHN'S DATA STORY

bottom of page