|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Detecting Multiple Changes | |
I want to write a trigger to detect changes to columns in SQL Server 2022. I have this table:
CREATE TABLE CustomerLarge (CustomerID INT NOT NULL IDENTITY(1, 1) CONSTRAINT CustomerLargePK PRIMARY KEY CLUSTERED , CustomerName VARCHAR(20) , CustomerContactFirstName VARCHAR(40) , CustomerContactLastName VARCHAR(40) , Address VARCHAR(20) , Address2 VARCHAR(20) , City VARCHAR(20) , CountryCode CHAR(3) , Postal VARCHAR(20) , creditlimit INT , discount NUMERIC(4, 2) , lastorderdate DATETIME , lastorderamount NUMERIC(10, 2) , lastordercontact VARCHAR(20) , created DATETIME , modified DATETIME , modifiedby VARCHAR(20) , statusid INT , active BIT , customersize INT , primarysalesid INT); GOI want to determine if both the CustomerContactFirstName and CustomerContactLastName fields are changed, but no others. What is the mask I need to use with COLUMNS_UPDATED()? | |
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) |
Change Tracking and Database Compatibility I want to enable Change Tracking for a database. What is the minimum database compatibility level I need to set for the Changetable function to work correctly? Answer: 90 (SQL Server 2005) Explanation: While you can enable Change Tracking for database below 90, you will get an error from the ChangeTable function. You need to be at level 90 or above. Ref: Enable Change Tracking for a Database - https://learn.microsoft.com/en-us/sql/relational-databases/track-changes/enable-and-disable-change-tracking-sql-server?view=sql-server-ver16#enable-change-tracking-for-a-database |
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 2019 - Development |
Replace with like join - I am trying to create and Update query based on a like join. Is that possible? This is what I have: UPDATE claim SET incident_desc = CASE WHEN incident_desc like '%' + NAC.Glyph + '%' THEN REPLACE(claim.incident_desc, NAC.Glyph, NAC.Replacement) ELSE incident_desc END FROM claim INNER JOIN NonASCIICharacters NAC ON claim.incident_desc LIKE '%' + NAC.Glyph + […] |
built in deadlock information capture - Hi, i cannot recall the object or even if it comes off the shelf but i once saw a tool in sql server where the competing tables etc involved in a deadlock are recorded. I think you had to know a bit about the complicated looking test it provided but it was sweet. my recollection […] |
Anything that is NOT about SQL! |
NKTg Law on Varying Inertia – A Different Way to Think About Motion - Hi everyone, I’d like to share something from the science side of life rather than the SQL side. It’s called the NKTg Law on Varying Inertia. In classical mechanics, Newton’s laws describe how objects move under the influence of forces. But the NKTg Law takes a different angle: instead of focusing only on forces, it […] |
Editorials |
Who is Using Standard Edition? - Comments posted to this topic are about the item Who is Using Standard Edition? |
Carrots and Sticks - Comments posted to this topic are about the item Carrots and Sticks |
Storage Enhancements - Comments posted to this topic are about the item Storage Enhancements |
Everyone Wants a Piece of the AI Pie - Comments posted to this topic are about the item Everyone Wants a Piece of the AI Pie |
Article Discussions by Author |
How to create your custom GPT SQL Expert - Comments posted to this topic are about the item How to create your custom GPT SQL Expert |
MongoDB and NodeJS in action - Comments posted to this topic are about the item MongoDB and NodeJS in action |
SQL Server 2022 - Administration |
Index Consolidation - I am trying consolidate indexes in the production environment and whilst I have a good idea of what or how to about the actual index consolidation, my challenge is how to test this process to ensure that stored procedures or processes calling on tables are using the indexes they would normally have used so for […] |
CDC job running for 17 days? - Good morning, I've noticed my CDC job running for 17 days. I've noticed it before, but wasn't sure it was an issue. I've checked sys.databases to check the log_reuse_wait_desc to see if it said "replication". It says nothing. The Database is 8 TB and the log file is 23 GB. I queried : SELECT job_id, […] |
Database growth events for unidentified databases - We have recently upgraded from SQL Server 2016 to 2022 Standard Edition. Our nightly reports have started showing regular growth events for the following database files (see attached). model_replicatedmaster (both the replicatedmaster and replicatedmasterlog files) model_msdb (both the MSDBData and MSDBLog files) Firstly, what databases are these? I'm familiar with model, master, msdb and tempdb […] |
distributed availability group query - Not sure if this is my misunderstanding or an error in my process: Create AG1 on server 1 & 2. (2019). Add DB1. Replica are joined, DB1 is synchronised. Create AG2 on server 3 & 4. (2022). Add DB2. Replica are joined, DB2 is synchronised. Remove DB2 from AG & drop on both. Create DAG […] |
SQL Server 2022 - Development |
ODCB error from Linux client - Hi Folks, When connecting to one of SQL Server 2022 servers , from a linux machine, there is this ODBC error . Strangely the same isql test is successful when I test against another SQL server 2022 server on a different server and also in the same VLAN. I can connect to both these servers […] |
azure vm has to be rebooted more often than we'd like - Hi we're noticing this 2022 server gets into a funk now and then. Specifically, i notice when i script existing tables to the clipboard etc it just hangs with that circle continuing to spin. i notice that if i reboot, the problem goes away for a while. does the community have a similar experience? […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |