Today I am posting a very useful query which is required when you want to make a dynamic script which will help you to create synonyms for all your tables within a database.Query is as follows,Run it on the required database.
select ‘create synonym syn_’ + t.name + ‘ for [‘ + DB_NAME() + ‘].[‘ + s.name + ‘].[‘ + t.name + ‘]’
from sys.tables t
inner join sys.schemas s
on t.schema_id = s.schema_id
where t.type = ‘U’
I would like to have feedback from my blog readers.
Please post your feedback, question, or comments about this article.