Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid object name when updating after renaming table

Have a very strange problem when trying to rename table and use it.
I have a table called oldTable and rename it to the newTable.
I can successfully use select on this table using:

SELECT * FROM database.dbo.newTable;

But when I try to use update like this:

UPDATE database.dbo.newTable SET foo = bar where id = 1;

I receive following error:

Msg 208, Level 16, State 1, Procedure archive, Line 4 [Batch Start Line 0]
Invalid object name 'oldTable'.

Looks like name oldTable was stored somewhere and is used here by some kind of reference. It happens on both ssms and raw php+sql when trying to update.
Anyone have any idea?

like image 861
Grzesiek Avatar asked Oct 18 '22 21:10

Grzesiek


1 Answers

Renaming a table will not update any Triggers that have been defined for the table (or any references to it anywhere else) so you need to manually update any triggers or other dependencies to reflect the new name.

like image 176
Alex K. Avatar answered Oct 21 '22 06:10

Alex K.