| Author |
Message |
paulo.morgado
Joined: 16 Aug 2006 Posts: 52 Location: Portugal
|
Posted: Fri Jun 11, 2010 3:02 pm Post subject: Smart Rename from columns wrongfuly substitutes name |
|
|
(SQL Refactor version 1.5.1.61)
I have a set of logging tables in my database that have the same set of columns of the table they are logging changes and some more log related columns. Log tables are populated through instead of insert, delete and update triggers of the logged table.
When I rename one column that's both in the log and logged table, SQL Refactor wrongfuly replaces the name of the column in the deleted and inserted tables. _________________ Paulo Morgado
Portugal
Web Site
Weblog
Twitter |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6346 Location: Red Gate Software
|
Posted: Mon Jun 14, 2010 10:06 am Post subject: |
|
|
Hello Paulo,
I'm not completely clear on what is happening. SQL Refactor can only smart-rename one column at a time, so the best assumption that I can make is that you are either smart-renaming a computed column, or the changes necessary to complete the smart rename are unnecessarily rebuilding tables (copying data to a new table, dropping the old one and renaming the temporary table back) and we have a patch that we can give you in case the latter is the problem.
Please let me know. _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
paulo.morgado
Joined: 16 Aug 2006 Posts: 52 Location: Portugal
|
Posted: Thu Jun 17, 2010 11:50 pm Post subject: |
|
|
Sorry for the late reply.
Just imagine you have this table:
| Code: |
CREATE TABLE [Log].[Test](
[Test] [nchar](10) NULL
) ON [PRIMARY] |
And this one:
| Code: |
CREATE TABLE [dbo].[Test](
[Test] [nchar](10) NULL
) ON [PRIMARY] |
With this trigger:
| Code: |
CREATE TRIGGER [dbo].[TestTrigger] ON [dbo].[Test]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON ;
INSERT INTO [Log].[Test]
( [Test] )
SELECT [Test]
FROM inserted
END |
If I use SQL Refactor to rename [Log].[Test].[Test] to [Column], the generated trigger script is this:
| Code: |
ALTER TRIGGER [dbo].[TestTrigger] ON [dbo].[Test]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON ;
INSERT INTO [Log].[Test]
( [Column] )
SELECT [Column]
FROM inserted
END |
_________________ Paulo Morgado
Portugal
Web Site
Weblog
Twitter |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6346 Location: Red Gate Software
|
Posted: Fri Jun 18, 2010 9:37 am Post subject: |
|
|
Hi Paulo,
To summarize, the problem is that the trigger is altered to select [Column] FROM Inserted? Is this supposed to remain as [Test]? _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
paulo.morgado
Joined: 16 Aug 2006 Posts: 52 Location: Portugal
|
Posted: Fri Jun 18, 2010 8:04 pm Post subject: |
|
|
Yes. Because it's a trigger for [dbo].[Test] and not [Log].[Test], which means that the structure of inserted is the same as [dbo].[Test], not [Log].[Test]. _________________ Paulo Morgado
Portugal
Web Site
Weblog
Twitter |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6346 Location: Red Gate Software
|
Posted: Mon Jun 21, 2010 9:47 am Post subject: |
|
|
Thanks for clearing that up. I have opened a bug for SQL Refactor - SR-889. We should be in touch with you if there are any updates. _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
|