473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Database alias name

How would I create a database alias name for the following database
testingdatabase.com
This database exisist on a remote server. I have tried using the database
name as

server.[testingdatabase.com].dbo.table

were server is a linked server using sp_addlinkedserver
[testingdatabase.com] is the database name
dbo is the instantance
table is the name of the table.

using select * from server.[testingdatabase.com].dbo.table producing the
following error.

unspecified error

I cannot change or rename the database for many reason's (Original programer
hardcoded this in a compiled app) don't have access to source code anyway.
I have not found any docs on database alias, found docs for server / tables
etc.

Thanks

Conrad

Jul 20 '05 #1
4 22691
news (ca*@digitalinc.net) writes:
How would I create a database alias name for the following database
testingdatabase.com
This database exisist on a remote server. I have tried using the database
name as

server.[testingdatabase.com].dbo.table

were server is a linked server using sp_addlinkedserver
[testingdatabase.com] is the database name
dbo is the instantance
table is the name of the table.

using select * from server.[testingdatabase.com].dbo.table producing the
following error.

unspecified error


I investigated the case, and it appears that neither MSDASQL (which
judging from the error message you are using) nor SQLOLEDB handles
this database name correctly.

One workaround is to use OPENQUERY:

SELECT * FROM OPENQUERY(server,
'SELECT * FROM [testingdatabase.com].dbo.table')

This I've tested and it works.

I was also playing with specifying a defalt database to sp_addlinkedserver,
but I could not get this to work. Yet an other idea, which I did not try, is
to use sp_addlinkedsrvlogin to map to a user which has .com database as
its default database.

I should also add that I have reported the problems with your query,
since it is obviously a bug, at least in case of SQLOLEDB.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Thnak you for your quick response.
Your workaround works but I have now hit anther limit the openquery method
only allows fro a 128 char string. This is ok for simple queries but some of
the queries are approx 180 characters.

Thanks...
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn*********************@127.0.0.1...
news (ca*@digitalinc.net) writes:
How would I create a database alias name for the following database
testingdatabase.com
This database exisist on a remote server. I have tried using the database name as

server.[testingdatabase.com].dbo.table

were server is a linked server using sp_addlinkedserver
[testingdatabase.com] is the database name
dbo is the instantance
table is the name of the table.

using select * from server.[testingdatabase.com].dbo.table producing the
following error.

unspecified error
I investigated the case, and it appears that neither MSDASQL (which
judging from the error message you are using) nor SQLOLEDB handles
this database name correctly.

One workaround is to use OPENQUERY:

SELECT * FROM OPENQUERY(server,
'SELECT * FROM

[testingdatabase.com].dbo.table')
This I've tested and it works.

I was also playing with specifying a defalt database to sp_addlinkedserver, but I could not get this to work. Yet an other idea, which I did not try, is to use sp_addlinkedsrvlogin to map to a user which has .com database as
its default database.

I should also add that I have reported the problems with your query,
since it is obviously a bug, at least in case of SQLOLEDB.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp



Jul 20 '05 #3
Conrad (ca*@digitalinc.net) writes:
Thnak you for your quick response. Your workaround works but I have now
hit anther limit the openquery method only allows fro a 128 char string.
This is ok for simple queries but some of the queries are approx 180
characters.


That seems strange. I can't find any such limitation, and I tried this
statement without problem:

SET QUOTED_IDENTIFIER OFF
go
SELECT * FROM OPENQUERY(REMOTSRV,
"SELECT o.OrderID, o.OrderDate, od.UnitPrice, od.Quantity,
c.CustomerID, c.CompanyName, c.Address, c.City, c.Region,
c.PostalCode, c.Country, c.Phone, p.ProductID,
p.ProductName, p.UnitsInStock, p.UnitsOnOrder
FROM Northwind..Orders o
JOIN Northwind..[Order Details] od ON o.OrderID = od.OrderID
JOIN Northwind..Customers c ON o.CustomerID = c.CustomerID
JOIN Northwind..Products p ON p.ProductID = od.ProductID
WHERE (o.OrderDate >= '19960101')
AND (o.OrderDate <= '19990601')
AND (od.UnitPrice >= 10)
AND (od.UnitPrice <= 100)
AND (o.CustomerID = 'ALFKI')
AND (c.CompanyName LIKE 'Alfred' + '%')
AND (c.City = 'Berlin')
AND (c.Region IS NULL)
AND (c.Country = 'Germany')
AND (od.ProductID = 76)
AND (p.ProductName LIKE 'Lakka' + '%')
ORDER BY o.OrderID")

I tried with both MSDASQL and SOLOLEDB.

I will however research if there is some workaround that permits you
to access the remote database without specifying the database name.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4
Conrad:
I cannot change or rename the database for many reason's (Original
programer
hardcoded this in a compiled app)

You may be able to circumvent this by creating an alias thru the SQL
Server Client network utility of "testingdatabase.com" that points to
a different database. Ofcourse this is not optimal if you have many
client machines.

I haven't tried this so don't take my word for it. But you may want to
play around with it...

HTH

BZ

"news" <ca*@digitalinc.net> wrote in message news:<vi************@corp.supernews.com>... How would I create a database alias name for the following database
testingdatabase.com
This database exisist on a remote server. I have tried using the database
name as

server.[testingdatabase.com].dbo.table

were server is a linked server using sp_addlinkedserver
[testingdatabase.com] is the database name
dbo is the instantance
table is the name of the table.

using select * from server.[testingdatabase.com].dbo.table producing the
following error.

unspecified error

I cannot change or rename the database for many reason's (Original programer
hardcoded this in a compiled app) don't have access to source code anyway.
I have not found any docs on database alias, found docs for server / tables
etc.

Thanks

Conrad

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: gdabbara | last post by:
Hi, We have a situation where we want to move our current database server to a different hardware and rename the server. If we change the Physical server name, do we have to go thru the whole...
20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
5
by: Alias | last post by:
Hi Guys , I am trying to create a federated database link between 2 UDB 8.1 databases running on AIX on the same box but under different instances. When i tried this thru the control centre , I...
1
by: Harlin | last post by:
Hi, I am trying to set up the database for LMS on a Linux box. This box is running SLES 9. I am trying to run the following scripts as user: db2inst1 : ../cr_db2db_audit.sh and I receive...
0
by: mel_apiso | last post by:
Hi, after uncatalog one database, and catalog again with other name, if I try to connect with this database, everything is ok, but list applications only show me the connection with the...
1
by: BCC | last post by:
Is there a way to create an alias that points to a databse? example : database name Retail Database desired result : declare an alias say Retail so everytime I refer to Retail it will point to...
1
by: dwasler | last post by:
Try every thing I know to remove this alias I know there been other posting I read each one none seem to work. Thank You DLWasler dwasler@yahoo.com OS Window db2 V 8.2.X
1
by: HarryW | last post by:
Hio, I want to update teh database Slim98 with some values out of database Slim0. The databasestructure is equal. update Slim98.dbo.article set Slim98.dbo.article.insuranceinventory =...
2
by: jelle79 | last post by:
Hi all, I'm storing all kind of data stored in objects. Now I want to query my data-source. And I thought LINQ is the right thing for it. Data is stored like: store.Database Queries like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.