Need help if anyone can offer!

I currently have my select statement returning the TOP 1000 * results from a table. They are CC numbers that are currently active. I'd like to see how I can go about writing a query that could show me what has CC numbers have changed.

If something has changed, it will send a report to the listed people. If nothing, then it does nothing. It only actions once something has happened. We have an inhouse system that will do the automated part... I just need a select statement that will return what has changed. If I can get some help on this, it would be amazing!

Thank you!


If you're not already logging changes yourself in your user defined tables, then you'll need to implement a feature that does so for your. Here is a list of features you can use to accomplish this:

  1. Triggers - Fire whenever data changes in a table, can implement logic similar to being in the context of a stored procedure.

  2. Temporal Tables - System versioned copies of the user defined tables that track changes.

  3. Change Tracking - Automated tracking of changes for your user defined tables.

  4. Change Data Capture - Keeps track of DML changes to the specified user defined tables.

  5. Audit - Automatically tracks a multitude of actions at the server level.


That is exactly what triggers do. Please have a look at https://www.sqlservertutorial.net/sql-server-triggers/ or https://www.sqlshack.com/triggers-in-sql-server/ or https://www.mssqltips.com/sqlservertip/5909/sql-server-trigger-example/ you will find more information.

If you just need an update trigger it will be something like:

create trigger triggername on yourtable for update as begin yourcommands end;

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.