SYNONYM Question
Oct 4, 2006
Is it possible to create a SYNONYM that does not require you to use the owner prefix? Similar to an Oracle PUBLIC synonym.
for example:
CREATE SYNONM MySynonym FOR dbo.myfunction.
SELECT MySynonym FROM dbo.mytable;
View 3 Replies
ADVERTISEMENT
Apr 12, 2006
Suppose that a synonym foobar exists pointing to the table foo.bar. I also have a table with the same name in my schema. (mpswaim.foobar)
If I do a select
select * from foobar
Which table does the select run against? mpswaim.foobar, or foo.bar?
In Oracle, mpswaim.foobar would win, and we used this to all ow individual developers to have their own version of application tables during development.
View 1 Replies
View Related
Jul 15, 2006
I get an error in query analyzer when running (parsing query):
CREATE PUBLIC SYNONYM LIB_GROUP_PERMITS FOR LIB_GROUP_PERMITS;
with an error of:
"Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'PUBLIC'."
Can anyone help me at all please!
Thanks!
View 3 Replies
View Related
Apr 28, 2004
Hi all. Informix and DB2 support something called synonyms that allow you to basically create sort of an alias for a table at the database level. Think of it sort of as a shortcut or link to a table. Does SQL Server 2000 have a similar ability and if so how?
I know someone will ask why you want to do this, so heres a quick example:
If you have one legacy application that expects to write to one particualr table, but you wish to partition that table across several tables, you can break table1 up into tablea,tableb,tablec and then create a synonym called table1 that would point to only the appropriate table at the appropriate time. This way you can break a huge HUGE table up into logically discreet smaller tables and manage the creation of the appropriate synonym in some wrapper that sits in front of the legacy application...thus allowing you to retool a table that has outgrown its original design without having to crack open dreaded legacy code.
So, anyone?
View 1 Replies
View Related
Feb 25, 2008
I ran the following command to create a synonym for a function -
create synonym testfunc for myschema.myfunc
Then testfunc will be created in the dbo schema. When I call this function from my stored procedure by 'testfunc', I received an error indicating 'testfunc' is not a recognized build-in function name. If I call it by 'dbo.testfunc' then it will work.
If I create a synonym for a table, I can access the table using the synonym in my stored procedure without any problem.
Is it true that synonym works differently on tables vs. functions?
View 4 Replies
View Related
Oct 23, 2006
I may just be completely missing something here but, when I view a query plan from a SQL statment that involves a join with a synonym I do not see any reference to the synonym or the underlying table referenced by it in the query plan? Any thoughts?
Thx!
View 5 Replies
View Related
Aug 15, 2006
Can anyone tell me why I am getting this error when I try to select * from a table through a newly created synonym? I have admin rights to both db, but they are on separate servers.
<Error>
OLE DB provider "SQLNCLI" for linked server "srvDEV" returned message "Communication link failure".
Msg 10054, Level 16, State 1, Line 0
TCP Provider: An existing connection was forcibly closed by the remote host.
Msg 18456, Level 14, State 1, Line 0
Login failed for user 'NT AUTHORITYANONYMOUS LOGON'.
</error>
<code>
CREATE SYNONYM ARContractTerms_syn FOR srvDEV.EricsAdeptCastle.dbo.tblARContractTerms
SELECT * FROM ARContractTerms_syn
</code>
Am I running into schema problems?
Thanks all
Microsoft SQL Server Management Studio 9.00.2047.00
Microsoft Analysis Services Client Tools 2005.090.2047.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600
View 2 Replies
View Related
Mar 17, 2007
I am working with SQL Server 2005, here is what I am doing:
declare @cx as varchar(100)
set @cx = substring(db_name(), dbo.instrrev('_', db_name()) + 1, datalength(db_name()) - dbo.instrrev('_', db_name()))
exec ('CREATE SYNONYM tblsynonym FOR ' + @cx + '..TableName')
---Procedure
drop synonym tblsynonym
The application i'm working on uses stored procedures that will at some point be called by more than one user at a time. At the start of the stored procedure the synonym is created and then it is dropped when the procedure completes, the issue is this: if two users access the same stored procedure at the same time then the first procedure will create the synonym and the second will fail because the syonym already exists.
Here is what I would like to do:
declare @cx as varchar(100)
declare @timestamp as datetime
set @cx = substring(db_name(), dbo.instrrev('_', db_name()) + 1, datalength(db_name()) - dbo.instrrev('_', db_name()))
exec ('CREATE SYNONYM tblsynonym' + @timestamp + ' FOR ' + @cx + '..TableName')
---Procedure
drop synonym tblsynonym
Any ideas??????
View 7 Replies
View Related
Jan 25, 2006
I'd like to use a data flow task to load data into a table by specifying the synonym name of the destination table, instead of the actual table name.
The OLE DB Destination is forcing me to pick an actual table or view from a drop down list. Any ideas on how to get around this?
Thank you.
View 4 Replies
View Related
Apr 16, 2015
I'm using SQL Server 2008R2. I am developing a database which requires access to data from other servers. So far I have been creating views using OPENQUERY (where there's a performance benefit) to select specifically the columns I want. Generally, for my purposes, I find these OPENQUERY based views to perform better (some times significantly so) to simple SELECT <COLUMNS> FROM <SERVER>.<DATABASE>.<SCHEMA>.<TABLE> WHERE <Where clause Statements> format views. My understanding is that this is because an OPENQUERY "pushes" the query processing to the remote server and simply returns the final result set to the local server i.e. there's no cross-server join/synchronization going on.
My question is, if I were to create a Synonym for a table object on the remote server, where does the processing happen if I query from this Synonym or create a join with this synonym to a table in my local database?Essentially, I am trying to understand if there are any "hidden gotcha's" primarily from a performance perspective, to using synonyms.
View 1 Replies
View Related
Apr 23, 2015
A heavily-selected database will be in an inconsistent state for several hours during a batch process. For that time, a database snapshot is created and accessed instead. To allow constant client read access to the database, a database that only contains synonyms exists. Those synonyms point to the main database except during the batch process, at which time they point to the database snapshot.
To switch the synonyms, each synonym is dropped and then created pointing to the database snapshot (after its creation, of course). The drop/create occurs inside a transaction. Roughly, the SQL looks like this:
SET XACT_ABORT ON;
BEGIN TRANSACTION;
DROP SYNONYM [dbo].[some_proc];
CREATE SYNONYM [dbo].[some_proc] FOR [snapshot_db].[dbo].[some_proc];
GRANT EXECUTE, SELECT ON [dbo].[some_proc] TO public;
COMMIT TRANSACTION;
When the batch update is completed, the process is reversed with "snapshot_db" replaced with "regular_db". The SQL snippet above is dynamic SQL. What I've pasted is the dynamic SQL that is executed as a single batch.
While this switch is happening, clients are accessing the procedures through the synonyms, potentially at a high request rate. Testing reveals that clients can get the error:
Error=-2147217900, Id=0, Meaning=IDispatch error #3092,
Source=Microsoft OLE DB Provider for ODBC Drivers,
Description=[Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'dbo.some_proc'.
This error only occurs once. If the same SPID retries its request and the transaction has not completed (for testing, a delay was added), then it blocks until the transaction completes.
Any way to prevent it besides a client-side retry?
View 2 Replies
View Related
Jun 17, 2014
I need to get the object type (view, table ...etc) for a synonym base object inside a script. The only place where I see something related to this stored is in column "base_object_name" in sys.synonyms but there I can see only the same with format [database].[user/schema].[name]. After some testing playing with different users without specifying database/schema I think that maybe the object_id must be stored in a another place, my first idea was parent_object_id in sys.synonyms but it isn't stored there.
know if object_id for the base object is stored in any other place ?
View 6 Replies
View Related
Jul 10, 2007
how can I create a database synonym for the actual database name?
View 3 Replies
View Related