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

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


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]  


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s