Reputation: 11
I have to write a number of queries in SQL Server Management Studio, most of which, however, are not in my current database, but to a remote one. So, any simple select query looks like:
select * from [top_database].subdatabase.subsubdatabase.actualtable
where all I want to do is write
select * from actualtable
Is there any way that I can customize SQL Server so that I hit some hotkey or expand a very minimal text which will then give me
[top_database].subdatabase.subsubdatabase.
right after my cursor?
Thanks
Upvotes: 0
Views: 668
Reputation: 138960
You can create a synonym to your remote tables and use that synonym when you write queries. You can have a db at your server with all the synonyms you are likely to use. More work the first time you query a table but less work the next time.
create synonym TableName for LinkedServerName.DataBaseName.SchemaName.TableName
Then you can do
select *
from TableName
Not really an answer to your question but it could be helpful.
Upvotes: 0
Reputation: 86716
Do you actually mean...
[linker server].[data base].[schema].[object]?
If so, as far as I am aware, you have to specify all parts of this. Intelli-sense exists in later versions of management studio, but I am not aware of it being able to expand names that exist on a linked server.
(I presume this is because the SQL Server, not the management studio client, would need to open a connection to the Linked Server to ascertain that information.)
Upvotes: 1