Query SQL Server from Oracle - force metadata refresh - sql-server

I am a SQL Server developer, with a task in Oracle. DBA set up a DBLink in Oracle that points at a SQL Server database. I am writing a view on the SQL Server data and then a view on the Oracle side to join it with additional Oracle data.
Problem: if I change the definition of the view on SQL Server, even "Select * From myview#dblink" errors with "Invalid column." Closing TOAD and reopening seems to correct the problem, but the real question is how to force Oracle to re-read the metadata without resetting the connection?

This sounds like an issue with TOAD, not oracle. What happens if you do it in SQL*Plus?

I dont know if I understand you but if you got a dblink that points to a SQL server DB in your Oracle DB and you need data in SQL server just do:
SELECT *
FROM TABLE#dblink
SELECT "COL", "COL2", "COL3
from TABLE#dblink
SELECT T."COL", H."COL"
FROM TABLE1#dblink T, TABLE2#dblink H
WHERE T."ID" = H."ID"

Maybe you can do?:
alter view <<view_name>> compile;
I haven't tested this because I have no db link from Oracle to MSSQL.

This seems to be an issue with the Oracle 10g client. The current solution is to disconnect and reconnect. Given that I haven't been able to find anyone else with this problem, i will assume that it is a problem with my client config.

Related

Message "cross-database references are not implemented" for a simple query from SQL Server to PostgreSQL

I need to query PostgreSQL from SQL Server. I created a linked server connection (ODBC for PostgreSQL, the newest). It works on some schemas and not on the others. They're all on the same server.
For example this works:
SELECT * FROM LinkedPS.MyDatabase.Schema1.Table1
and this doesn't:
SELECT * FROM LinkedPS.MyDatabase.Schema2.Table2
I wasn't able to find any property which would cause this.

How to add Sybase SQL Anywhere DB as linked server to MS SQL Server properly

I used the Microsoft OLE DB Provider for SQL Anywhere to create a linked server, it shows remote databases and tables, I can read data, but writing data seems to work only using OPENQUERY() and when doing the connection_authentication using EXEC ... AT ... directly in the script.
How can I have the SQL Server do the authentication automatically when opening a connection?
How can I make normal write operations work without OPENQUERY()?
Sorry for not adding detailed error messages, I will add them later maybe, when I have access to the server again... But they were not meaningful anyway, i.e. when the weird authentication was missing, it just said "could not insert" or "failed" instead of indicating any authentication issue.
How to get the real error messages that come from Sybase?
Details:
SAP Sybase SQL Anywhere 16 (OEM Authenticated Edition) <-> MS SQL Server 2014
EXEC 'SET TEMPORARY OPTION CONNECTION_AUTHENTICATION=''Company=...''' AT linkedserver
INSERT INTO OPENQUERY(linkedserver, 'SELECT column FROM table WHERE 0=1') VALUES ('')
...that's not nice.
Even more details:
This is how I created the linked server
This is the authentication I'm talking about

Creating SQL Server database without the /MSSQLSERVER in the connection string?

I found this pretty weird thing when I first installed SQL Server 2008, for some reason there are two things that I want to get rid of and I can't:
If my computer name is, say, ABC, then I always have to connect to ABC/MSSQLSERVER for the server name when I log in from the SQL Server client, instead of using just using ABC, may I know how I can do that?
How can I default the DB so that if I have multiple DB on the server (System DB + my real DB), I can always default to use my real DB without saying "Use MyRealDB" every time?
Thanks a lot!
Regards,
Anyi
1) When installing, you picked a named instance.
2) In user admin, you can specify the default database per user.
What's happened here is that your SQL Server is installed as a named instance. To remedy this, you'll have to remove and reinstall SQL Server.

On SQL Server 2008, how to find out when was any database offline/online?

I have to include one report in my application showing offline/online activity of few databases on SQL Server 2008.
Could you please suggest how can I collect teh same information from sql server?
SELECT DATABASEPROPERTYEX('YOURDATABASE', 'Status')
DatabaseStatus_DATABASEPROPERTYEX
GO
SELECT state_desc DatabaseStatus_sysDatabase
FROM sys.databases
WHERE name = 'YOURDATABASE'
GO
This will tell you the status of the database.
In order to find out when your database was taken OFFLINE, you can use the SQL that I posted before, or the easiest way is to check the Event Viewer and it will tell you when the Database was taken OFFLINE. I have just tested this on my local machine and SQL Server writes out an Information message to the Application log.
You can also use below query to check database status.
SELECT Name, state_desc FROM sys.databases

Querying a view that's not located on the same server (SQL Server 2005)

I'm trying to query a database view that's not located on the same server as the stored procedure I'm running.
I heard about using "linked servers", but I have no access to the server's configuration at all ...
Thanks in advance !
Use OPENDATASOURCE:
SELECT *
FROM OPENDATASOURCE(
'SQLOLEDB',
'Data Source=ServerName;User ID=MyUID;Password=MyPass'
).Northwind.dbo.Categories
You can do this, but it does require the DBA to set up the link. If you don't have access to the server's configuration and the DBA is not on board, you're out of luck.

Resources