Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

Capturing Data Changes

While working with a customer recently, I saw some code from them that used the OUTPUT and INTO clauses of an UPDATE statement to capture the changes made into another table. In this case, as users updated code strings in a table used in dynamic SQL, the developers wanted to capture the history of those changes in another table, giving them a rollback strategy if there were problems. This is an interesting, and focused way of auditing data changes, albeit with the work to write this code and control updates through stored procedures.

This is one way of tracking the history of data values in many database platforms. Temporal tables are another, and we have CDC/Change Capture available in SQL Server. In the past, many people have used triggers. All of these work, with various pros and cons. In many cases, I have seen triggers used, often because many developers know how to write them and they are easy to create. Easy to get wrong as well.

However, triggers take some work, while platforms have often built capabilities that make it easy to capture data changes and track them. Many developers often aren't aware of these features, or haven't spent sufficient time with them to know how to work with them or if these features even work well. This is one reason many of us write about new features, to learn about them, experiment, and help others to understand how to use them. Of course, not all features turn out to be as great as marketed.

Today I wonder how you capture changes and audit them. Do you use triggers? Something built in? For limited auditing, and with control of the code, would you use the OUTPUT clause with your insert/update/delete code? Actually, I wonder how many of you would even consider this for limited auditing, especially with the large number of tools and frameworks that might generate their own UPDATE statement rather than call a stored procedure where you control the code. Or do you think this isn't a good way to capture this data.

Steve Jones - SSC Editor

Join the debate, and respond to today's editorial on the forums

 
 Featured Contents
SQLServerCentral Article

Passing parameters to query without TVFs

seanachim@hotmail.com from SQLServerCentral

This article looks at an interesting way to help your users get filtered data from a TVF instead of using a stored procedure or specialized view.

External Article

How to use the SQL WHERE Clause with Examples

Additional Articles from MSSQLTips.com

With the SQL WHERE clause in SQL Server, users can filter their query results in many ways. In most cases, we do not utilize all the options the WHERE clause provides, so we tend to forget that they exist. In this SQL tutorial, we will look at several examples of how to use the WHERE clause.

External Article

Database Monitoring: The ROI of Build vs. Buy

Additional Articles from Redgate

In this webinar, Microsoft Data Platform MVP, Grant Fritchey, is joined by our expert panel to share the pros and cons to building a monitoring system versus purchasing one.

Blog Post

From the SQL Server Central Blogs - KQL Series – ingesting data with Azure Data Factory

HamishWatson from The Hybrid DBA's Blog

Background: Azure Data Explorer is a powerful analytics service that allows us to quickly ingest, store, and analyze large volumes of data from various sources. Azure Data Factory is...

Blog Post

From the SQL Server Central Blogs - Building, Deploying, Sharing a Remote Jupyter Book in Azure Data Studio

DataOnWheels from DataOnWheels

When working with Azure Data Studio and its support of Jupyter books, you will find there is an option for remote Jupyter books. As shown in the image below,...

Pro Encryption in SQL Server 2022

Pro Encryption in SQL Server 2022: Provide the Highest Level of Protection for Your Data

Additional Articles from SQLServerCentral

This in-depth look at the encryption tools available in SQL Server shows you how to protect data by encrypting it at rest with Transparent Data Encryption (TDE) and in transit with Transport Level Security (TLS). You will know how to add the highest levels of protection for sensitive data using Always Encrypted to encrypt data also in memory and be protected even from users with the highest levels of access to the database. The book demonstrates actions you can take today to start protecting your data without changing any code in your applications, and the steps you can subsequently take to modify your applications to support implementing a gold standard in data protection.

 

 Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

Managed Instance Link and SQL Server 2022

What does the Managed Instance Link allow me to do with SQL Server 2022?

Think you know the answer? Click here, and find out if you are right.

 

 

 Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Adjusting DOP based on Feedback

In SQL Server 2022, there is an intelligent query processing feature that adjusts DOP based on feedback. When this feature works, how does it adjust DOP for queries?

Answer: It adjusts DOP down from the settings to minimize parallelism

Explanation: This feature is built to adjust DOP down only to minimize CPU and parallelism. Ref: DOP Feedback - https://learn.microsoft.com/en-us/sql/relational-databases/performance/intelligent-query-processing-feedback?view=sql-server-ver16#degree-of-parallelism-dop-feedback

Discuss this question and answer on the forums

 

 

 

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.


SQL Server 2017 - Administration
optimize for adhoc workload setting - Hi Experts, What is 'optimize for ad hoc workloads' do mean in short? I hae read it as it minimizes plan cache bloating. Do we really need to set this settig? What is the benefit we get if we set 'optimize for ad hoc workloads' = 1. How to verify if we really have to […]
Performance comparision - Hi All, We are trying to compare UAT performance vs Prod performance. The UAT is having much better performance. Production: We have this one big database with 2.5TB. Its 3 node Alwayson setup. Two synchronous replica in one region and one asynchronous replica in a different geographical reason. Prod has 30 databases. 16 CPUs 256 […]
Performance issues after migration - Hi all, We installed SQL 2017 standard edition. Taken the 2008r2 server database backup and restored into new 2017 server. Didn’t change the compatibility level. Same memory allocated as 2008r2 and did the update stats but seeing performance issues.
Alwayson SQL Agent Job must be executed only on PRIMARY - Hi All, We have an SQL 2017 Always on AG in our environment. We have few update stats job which we wanted to run only on PRIMARY replica. we create the jobs on both replicas but it should execute only on PRIMARY replica. For that, we are trying to use this logic. Not sure, why […]
Development - SQL Server 2014
TVF - Table Variable - Query takes 52 minutes........... - Hello. We have inherited a system and some code and this has been flagged as a performance issue. In fact the query times out and never completes and running it in SSMS shows it took 52 minutes to complete. We have pretty much narrowed the issue down to the use of a TVF, and the […]
SQL 2012 - General
Bcp queryout issue - Hi all, I am running the following query in SQL, trying to export some data to a csv file, with header. When I try to execute it from SQL server, it exports only the header and not the row data as well. When I print it and execute it from cmd, the file contains the […]
SQL Server 2019 - Administration
Azure SQL - Restore to lower enviornment - Hello! Backups are automated for Azure SQL Prod environment, we can do point-in-time recovery if anything happens with the database in the same environment. But, how can we restore the production database\bacpac to lower environment without having to take manual bacpac? What can be done to monthly refresh lower environment from automated production bacpac? Thanks. […]
Cluster failed over, now we see critical errors but DBs are all "Synchronized" - Our cluster failed over from Server1 to Server2 during a patching reboot. So now Server2 is Primary and Server1 is Secondary. I'm not 100% familiar with Availability groups and replicas, so am looking for some help to resolve the issue In SSMS -> Server -> Databases on both Server1 and Server2, all DBs are showing […]
SQL Server 2019 - Development
SSIS Connection Manager Error - Hi Everyone I am working on a SSIS package.  There are multiple steps in the SSIS package design so I created 5 different SSIS packages - one for each step.  Now, I want to put them all in one SSIS package.  I created a new master SSIS and intend to copy and paste all the […]
Indexing Tables - Hi everyone I need to construct indexes for two tables. Table 1 - 30 Fields There are about 8 fields that are used in various SP where these fields are used for sorting and joining tables Table 2 - 7 Fields There are 3 fields that are used in various SP where these fields are […]
Records Are Not Sorted by Date - Hi everyone I am working on a SSIS package that converts a table into CSV file.  I need the CSV records to be sorted by date.  I have 7 other tables and they are working as expected except for 1.  I am not sure why the records are not sorted by date. I was getting […]
SQL Server 2005 Integration Services
SSIS connection manager password update - Hello, I have 3 SSIS packages having connection manager defined with a userA. These 3 packages executes via a SQL server job. I need to change the password of userA in all the 3 packages. Do I need to do it manually by opening the package first in Visual studio & updating the password in […]
SQL Server Newbies
Suggestion Req for Best SQL Courses - Hello this is Gulshan Negi I am a Software Developer, well I'm looking for SQL courses that are designed for advanced users whereas I already have a basic understanding and good commands of SQL. I'm looking to master SQL and would like to find courses that will help me improve my skills in areas such […]
Third Party Products
Anyone else HOT with how Red-Gate rolled out SQLHISTORY? - If you recently upgrade SQL Prompt to a recent version that has SQL History you were in for a rude surprise.  RG (Red-Gate) didn't simply add a new feature named SQL History to SQL Prompt, they replaced the  Tab History feature with SQL History and it is a really bad feature. The RG user forums […]
SQL Server 2022 - Development
SQL Server RLS Database Users and Login User Permission - Please suggest practice on SQL Server RLS On the database level, defined users with different permission policy e.g **DB_User1, DB_User2, DB_User3, DB_User4 ** When I create login User DB_User_manager How to specify that that use it can EXECUTE AS only DB_User3, DB_User4 and not DB_User1, DB_User2. Or if it is not possible, what is a […]
 

 

RSS FeedTwitter

This email has been sent to {email}. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -