Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 a way to shorten database name in query

Author  Topic 

HenryFulmer
Posting Yak Master

110 Posts

Posted - 2011-07-28 : 20:32:53
I am dealing with a legacy database that I have to address via IP and it has very long and non standard naming like:


SELECT *
FROM [66.12.34.5].VERYLONNGDATABASENAME.dbo.[Even Longer Weird Table Name with Spaces]


Is there a way to set up something like an alias that can be used instead of always having to type it out?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-07-28 : 21:48:55
how about using SYNONYM ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-07-28 : 22:59:03
Agree that a synonym is the way to go here. Here's a couple of articles regarding it:

http://www.pressthered.com/sql_server_synonyms_and_linked_servers/
http://nimtug.org/blogs/simon/archive/2009/09/18/using-sql-server-synonyms-in-queries-using-linked-servers.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -