We execute the following statement:ĮXECUTE. For this example, we are just going to use the Development servers.įirst, we are going to create a Stored Procedure on the Development2 server. You can create a slightly more complicated Stored Procedure. This code will work on all of the ‘2’ serversĪdding some depth to Synonyms. Now we can implement the code to create the stored procedures necessary on each environment. If accessing another database server, you will need permissions on that database server as well.įOR. To create a Synonym, you will need to have CREATE SYNONYM rights on the local database. Now we will implement a Synonym and see what the difference is on the code in the different environments.įirst, we create the synonyms on the ‘1’ servers. There is only one such call in this example, but in much larger procedures there can be dozens accessing different Tables, Views, Stored Procedures, Functions, etc. įor simple code such as this, changing the four-part call is not a significant amount of work. Let us start with a few basic Stored Procedures using four-part calls, one for each environment. As well the databases in use is one of the AdventureWorks databases from Microsoft. In this case all the ‘1’ servers are the source and the ‘2’ servers are the target servers. In this instance we are going to use sample servers just to help illustrate what is occurring. Syntax from Microsoft to create a Synonym for both on premise and in Azure SQL Server SyntaxĬREATE SYNONYM synonym_name FOR One of the areas where Synonyms come into their own is when they are used to abstract the four-part calls necessary when querying database objects via Linked Servers. Synonyms are database objects that can be used to reference other database objects, on remote servers or on the same server. First thing, Synonyms are not another way to link two servers together, that is bailiwick of Linked Servers.
0 Comments
Leave a Reply. |