SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


create synonym to schema


create synonym to schema

Author
Message
erics44
erics44
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3014 Visits: 739
Hi
I have a dev database and a live database

both have linked servers to other databases in the dev environments and live environments

I would like to know if it is posible to create a synonym to a schema rather than an object

so In the dev database my synonym would be created something like

create sysnonym Server.TheSchema for [DevServer].[Databade].[TheSchema]

and in live

create sysnonym Server.TheSchema for [LiveServer].[Databade].[TheSchema]

This way I would only need to alter the information in my synonym rather than each time i reference a table.

I know the about doesnt work so i was hoping that there was a way.

Thanks
Lowell
Lowell
SSC Guru
SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)

Group: General Forum Members
Points: 184785 Visits: 41569
nope a synonym must point to an object ( an object that would exist in a databases sys.objects view), and not part of the name of an object.

so by definitions, it is typically used for tables , views etc. very handy for aliasing four part objects, like CREATE SYNONYM myTable FOR OtherServer.Databasename.dbo.Tablename

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
anthony.green
anthony.green
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63348 Visits: 8598
Synonyms can be created for the following types of objects:

Assembly (CLR) Stored Procedure
Assembly (CLR) Table-valued Function
Assembly (CLR) Scalar Function
Assembly Aggregate (CLR) Aggregate Functions
Replication-filter-procedure
Extended Stored Procedure
SQL Scalar Function
SQL Table-valued Function
SQL Inline-table-valued Function
SQL Stored Procedure
View
Table (User defined) - Includes local and global temporary tables



How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


erics44
erics44
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3014 Visits: 739
thanks a lot for the replies guys
ScottPletcher
ScottPletcher
SSC-Forever
SSC-Forever (46K reputation)SSC-Forever (46K reputation)SSC-Forever (46K reputation)SSC-Forever (46K reputation)SSC-Forever (46K reputation)SSC-Forever (46K reputation)SSC-Forever (46K reputation)SSC-Forever (46K reputation)

Group: General Forum Members
Points: 46933 Visits: 8049
Nope, you have to synonym every object:

[LiveServer].[Databade].[TheSchema].[ObjectName1] --> [DevServer].[Databade].[TheSchema].[ObjectName1]

[LiveServer].[Databade].[TheSchema].[ObjectName2] --> [DevServer].[Databade].[TheSchema].[ObjectName2]

etc.

SQL DBA,SQL Server MVP(07, 08, 09) Prosecutor James Blackburn, in closing argument in the Fatal Vision murders trial:
If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search