Red Gate forums :: View topic - Smart Rename from columns wrongfuly substitutes name
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Refactor 1
SQL Refactor 1 forum

Smart Rename from columns wrongfuly substitutes name

Search in SQL Refactor 1 forum
Post new topic   Reply to topic
Jump to:  
Author Message
paulo.morgado



Joined: 16 Aug 2006
Posts: 52
Location: Portugal

PostPosted: Fri Jun 11, 2010 3:02 pm    Post subject: Smart Rename from columns wrongfuly substitutes name Reply with quote

(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
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6582

PostPosted: Mon Jun 14, 2010 10:06 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
paulo.morgado



Joined: 16 Aug 2006
Posts: 52
Location: Portugal

PostPosted: Thu Jun 17, 2010 11:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6582

PostPosted: Fri Jun 18, 2010 9:37 am    Post subject: Reply with quote

Hi Paulo,

To summarize, the problem is that the trigger is altered to select [Column] FROM Inserted? Is this supposed to remain as [Test]?
Back to top
View user's profile Send private message
paulo.morgado



Joined: 16 Aug 2006
Posts: 52
Location: Portugal

PostPosted: Fri Jun 18, 2010 8:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6582

PostPosted: Mon Jun 21, 2010 9:47 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group