- 论坛徽章:
- 0
|
baiynije 发表于 2013-01-29 16:25 ![]()
請教一個問題,修改表名後一定要重建存儲過程嗎?
用sp_recompile重新編譯一下可不可以?
Procedures and triggers that depend on an object whose name has been changed work until they are dropped and re-created.
1> create table test(id int, name varchar(20))
2> go
1> insert into test values(1,'baiynije')
2> go
(1 row affected)
1> select * from test
2> go
id name
----------- --------------------
1 baiynije
(1 row affected)
1> create procedure test_proc
2> as
3> select * from test
4> go
1> exec test_proc
2> go
id name
----------- --------------------
1 baiynije
(1 row affected)
(return status = 0)
1> sp_rename test,test_tbl
2> go
Object name has been changed.
Warning: Changing an object or column name could break existing stored procedures, cached statements or other compiled objects.
(return status = 0)
1> sp_recompile test_tbl
2> go
Each stored procedure and trigger that uses table 'test_tbl' will be recompiled the next time it is executed.
(return status = 0)
1> exec test_proc
2> go
Msg 208, Level 16, State 1:
Server 'xxxxx', Procedure 'test_proc', Line 3:
test not found. Specify owner.objectname o |
|