mssql 2008 r2 - How to remove and add dependencies to a table using query or stored procedures?
How to remove and add dependencies to a table using query or stored procedures?
Basically I have a table called A and it has a stored procedure dependency called B.
I want to cre开发者_开发问答ate a new table called C and add the stored procedure dependency to C and Delete A.
Are you trying to do this without modifying the stored procedure? Technically you could do this using a SYNONYM
(DROP TABLE dbo.A; CREATE SYNONYM dbo.A FOR dbo.C;
) - assuming you are on SQL Server 2005 or higher (please specify your version!) - but this can become a nightmare of spaghetti and cascading references.
Dependencies like you are talking about aren't created independently (pun intended). They are the result of the queries within the stored procedure.
To have the effect you are after you need to create your new table, and redirect the stored procedure to SELECT
/INSERT
/UPDATE
/DELETE
from C
instead of A
.
精彩评论