开发者

Call one Stored Procedure inside other Stored Procedure on different servers

开发者 https://www.devze.com 2023-01-15 12:21 出处:网络
How to execute one Stor开发者_JAVA技巧ed Procedure inside other Stored Procedure? NOTE: Both Stored Procedure\'s reside in different serversThe easiest, if you can on your system is (they must be li

How to execute one Stor开发者_JAVA技巧ed Procedure inside other Stored Procedure?

NOTE: Both Stored Procedure's reside in different servers


The easiest, if you can on your system is (they must be linked - click the link for information on linking Servers):

EXEC [RemoteServer].DatabaseName.ObjectOwnerName.StoredProcedureName

Have a look here for more information .

Also, for getting away from hard-coding server names, look at Paul's answer here involving Synonyms.


Further to @Kyles answer, you can add a synonym to remove the need for the longer / linked structure. This abstracts the server being referenced. So you could move the SP from UAT to LIVE environment and the code wouldn't have to change. The synonym with in the two environments would be set up on each server to correctly reference the other server in that environment.

0

精彩评论

暂无评论...
验证码 换一张
取 消