Forum Discussion
Mauricio1502
Feb 23, 2024Copper Contributor
How to detect that a column was renamed
Hi,
products like SQL Compare generates a script for all the changes that must be done to a target database, including column rename. How can I detect that with transact-sql? I can find inserted and dropped columns, even if a column with the same name has changed size or type, but I can't find a way to detect when a column was renamed.
Any help would be appreciated.
Thanks.
Mauricio
- olafhelperBronze Contributor
but I can't find a way to detect when a column was renamed.Mauricio1502 , your post is not very clear for me, what the situation is and what you are trying to achieve. SQL Server don't log such changes on it's own, you would have to implement an auditing on your own, e.g. using Create DML Triggers - SQL Server | Microsoft Learn
- Mauricio1502Copper Contributor
Hi olafhelper,
let's say we have a database in Development where we do some changes and a similar database in Production. We want to propagate those changes to Production Database. Products like SQL Compare (Redgate), makes a comparison between to databases and generates a script with all the required changes, new tables, indexes, columns added, dropped, changed or renamed, etc. I want to identify, particulary, when a column was renamed.
- olafhelperBronze Contributor
Mauricio1502 use a SSDT database project for changes: Use Schema Compare to Compare Different Database Definitions - SQL Server Data Tools (SSDT) | Microsoft Learn