Rename Form Table Name

Sadiq Mohammed asked on December 19, 2017 16:28

Hi,

I am trying to rename form table name and for that i have created a pagee which will list all forms with their table name and i am editing some table names and for that i am calling a procedure which has this sql below :

IF exists(SELECT c.ClassId FROM dbo.CMS_Class c WHERE c.ClassTableName = @ClassTableName) BEGIN DECLARE @msg varchar(100) = 'cannot update to table name ' + @ClassTableName; THROW 50000 , @msg, 1;
END DECLARE @ExistingTableName NVARCHAR(100);

SELECT @ExistingTableName = c.ClassTableName FROM dbo.CMS_Class c WHERE c.ClassID = @ClassId;


EXEC sp_rename @ExistingTableName, @ClassTableName;


UPDATE dbo.CMS_Class 
SET ClassTableName = @ClassTableName
WHERE ClassId = @ClassId;

CMS_Class also has ClassName field, do we need to update this field too ? also if you content stage from qa to prod after editing these table names will there be any issue i am going to face ?

Thanks

Recent Answers


David te Kloese answered on December 20, 2017 09:37

Hi,

if you rename any of Kentico's own tables you probably get errors for sure! Is there a good reason you want to rename table names? Is this a one time thing?

Since you seem to change the tables directly in SQL, Kentico's staging module wouldn't even know you've changed something.

Also it might be possible the table names are used in other (custom) queries or code...

So I'd be very careful updating tables names.

1 votesVote for this answer Mark as a Correct answer

Sadiq Mohammed answered on December 21, 2017 18:08

thanks for getting back, yes we do have good reason for doing it as some of those tables got created in Prod environment which we would never wanted hence having different ClassGUID when compare to qa. yes this will be a one time change and i am very sure that these tables are not used in any custom queries.

thanks

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.