You cannot ALTER SYNONYM in SQL Server 2005: DROP and RECREATE it


You can create SYNONYM in SQL Server 2005 with this syntax:

CREATE SYNONYM yourSynonym
FOR 
[[[server.][database].][schema_name].]object_name

If you want to change a synonym, there is no ALTER command to do it. You need to DROP and CREATE it again with new context.

Here is a sample:

IF  EXISTS (SELECT * FROM sys.synonyms WHERE name = N'mySynonym'
  

DROP SYNONYM [dbo].[mySynonym] 

CREATE SYNONYM [dbo].[mySynonym] FOR [myDB].[dbo].[myTable]  

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s