Am working on Sybase ASE 15.5.
I have 2 databases created in the same server, "DatabaseA" and "DatabaseB". The database owner is "User".
Logging in as "User" I created a table in "DatabaseB", called "TableA".
Now, my user has access to both database, but the default database is "DatabaseA".
This is sucessful when i login to DatabaseA:
USE DatabaseB
GO
SELECT * from DatabaseB.User.TableA
GO
But this is not:
USE DatabaseA
GO
SELECT * from DatabaseB.User.TableA
GO
It tells me that there is "No such object or user exists in the database".
I have Googled and most sites say that if the user has rights, then you only need to append the database and owner name to the table to access it. But it does not seems to work for my case.
I have tried creating a non DBO user "User2", and assigning it select rights using
GRANT SELECT ON DatabaseB.User.TableA to User2
and sp_helprotect shows that the rights is there for this user. But the results are exactly the same as when i query it with User.
Below is the result from sp_helprotect
grantor | grantee | type | action | object | column | grantable
'User' | 'User2' | 'Grant' | 'Select' | 'TableA' | 'All' | 'FALSE'
Is there anything configuration or setting that needs to be checked to enable this?
EDIT (22 July 2015)
Just discovered something. There are a few tables with DatabaseB that i can access from DatabaseA, but not all tables.
For example, there is TableA, TableB, TableC, and TableD in DatabaseB. Out of which TableB and TableD can be queried from DatabaseA using
USE DatabaseA
GO
SELECT * from DatabaseB.User.TableB
GO
SELECT * from DatabaseB.User.TableD
GO
which is sucessful. And
USE DatabaseA
GO
SELECT * from DatabaseB.User.TableA
GO
SELECT * from DatabaseB.User.TableC
GO
fails.
Help!!!
try SELECT * from DatabaseB..TableA
to fetch the result from different database
also you can do below
use DatabaseB
SELECT * from TableA
you must at least have read access to the database .
Just another example : Just another example:
select tabA.*,tabC.* from DatabaseB..TableA tabA, DatabaseA..TableC tabC
where tabA.xxx = tabC.xxx