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.
精彩评论