sougatamondal / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

RenameColumn - failure when the Column is RowGuidCol #43

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Database.RenameColumn("[CCO].T_Callout_Events", "incident_type_id",
"callout_event_type_id");
2.
3.

What is the expected output? What do you see instead?
- not sure of expected output/ but generally should be able to rename the
column.

actual result, is an exception with message about inability to change a
RowGuidCol

What version of the product are you using? On what operating system? With
what .NET implementation/version?
.net 2.0 on Windows XP

What database and version are you seeing this issue on?
sql server 2005

Please provide any additional information below.

Original issue reported on code.google.com by srikanth...@gmail.com on 2 Jul 2008 at 6:44

GoogleCodeExporter commented 8 years ago
sp_rename does not support renaming ROWGUIDCOL. We would need to change the 
entire
column rename strategy of SQL Server to support this. That still might not work?

Original comment by geoffl...@gmail.com on 4 Aug 2008 at 11:25

GoogleCodeExporter commented 8 years ago
What we've done in our project is just drop the ROWGUIDCOL and re-add it.

I'm not sure how this will affect any replication publications or subscriptions 
that 
you have, but it worked fine for me.

Original comment by subdigi...@gmail.com on 27 Oct 2008 at 5:11

GoogleCodeExporter commented 8 years ago
No @subdigital, dropping and re-adding it doesn't seem like a practical 
solution when 
dealing with a primary key that is related to many tables in huge databases. To 
solve 
your issue srikanth:
- Fire SQL 2005 management studio and open table in "design" view
- Highlight the column and go to Properties window
- Go to "RowGuid" property and set it to "No"
- Save the table
- Reopen in "design" view
- Rename column
- Set "RowGuid" back to "Yes"
- Save the table

Voila!

Original comment by nicholas...@gmail.com on 14 Jan 2010 at 9:40

GoogleCodeExporter commented 8 years ago
To apply nicholas.credli's method directly to Migrator.NET, surround the
Database.RenameColumn call with the following calls:

Database["SqlServer"].ExecuteNonQuery("ALTER TABLE tableName ALTER COLUMN
oldColumnName DROP ROWGUIDCOL");

Database.RenameColumn("tableName", "oldColumnName", "newColumnName");

Database["SqlServer"].ExecuteNonQuery("ALTER TABLE tableName ALTER COLUMN
newColumnName ADD ROWGUIDCOL");

Original comment by matthias...@googlemail.com on 10 Feb 2010 at 6:00

GoogleCodeExporter commented 8 years ago
In general case, you should also take into account foreign keys, that can use 
the 
column.

Original comment by dima117a@gmail.com on 11 Feb 2010 at 5:49