I used this query to determine what databases are using the 5 linked servers on a SQL server.
However, the results don't make sense to me. It is telling me that a server "DOMAIN" is being used by many databases for views, but when I look at the design of the view, I do not see [DOMAIN] in the SQL statement.
Example:
The query result shows me that the database [StrongMailTracking] depends on the linked servers [DOMAIN] and [SDMASQLSRV05.WISPUBS.UCG.COM] for the view [vw_SCP].
When I look at the design of [vw_SCP] I see:
SELECT DISTINCT ucontactid, vemail, vfirstname, vlastname, domain, vcompanymapped, vcompanyname
FROM SDMASQLSRV05.WISPUBS.UCG.COM.MarketingPromotions.dbo.selected_contacts_prelim AS a
When I go Linked Servers and expand DOMAIN, there aren't any tables or views. When I try to expand the System tables and views, I get an error:
Named Pipes Provider: Could not open a connection to SQL Server...
(Microsoft SQL Server, Error: 53)
Any thoughts on what's going on here?
Related
I have users with datareader permission on my sql, the problem is that i noticed that the users are doing "fishing" query a lot (they don't know what exactly should be querying to get what thy need).
This is a production SQL and we started to have deadlock because of those users.
Trying to don't break their process i applied "deny view definition to [user]" so they cannot see the list of tables, view, stored procedure, so no more "fishing"
This was a great solution, it works perfect if you connect directly to the SQL Server, you can run queries (select) but you cannot see the list of tables.
However many users are using those account to connect to our SQL using linked server, and when the run a query using the linked server they are getting error:
SELECT TOP 100 *
FROM [SERVERSQL].[DATABASE].dbo.[TABLE]
Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "SQLNCLI11" for linked server "SERVERSQL" does not contain the table ""[DATABASE]"."dbo"."[TABLE]"". The table either does not exist or the current user does not have permissions on that table.
Using SQL Server version 2014 (v12.0.2000.8) and 2016 (v13.0.5492.2).
What is the correct way to hide tables, view, stored procedures, etc but allow select and make it work on linked server?
Thanks
Linked server from one SQL Server to Another:
Linked server name is: PLWNSAVSQL02D which is SQL Server
This sql to linked server works:
select count(*) from [PLWNSAVSQL02D].[SFI_WMS].dbo.[TCOMPANYPALLETMESSAGES];
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
I am want to make the following statement:
INSERT INTO [Server_1\Instance_1].[Database].[dse].Table1
SELECT * FROM [Server_2\Instance_2].[Database].[dse].[**Table1**]
The point is the tables are on the different servers. I tried with the statement above. However, when I am on server_1 and when I run the following statement in order to retrieve the data from server 2:
SELECT * FROM [Server_2\Instance_2].[Database].[dse].[**Table1**]
... I get zero rows.
But when I run the statement above on the Server_2, I get a set of rows.
How can I transfer data from production to development server/environments?
I am using MS Management Studio.
UPDATE:
The error message I am getting when I run the select statement in order to retrieve the data from another (production) server:
The OLE DB provider "SQLNCLI10" for linked server "Prod_Server\Instance" does not contain the table ""Database"."dse"."BoxIteration"". The table either does not exist or the current user does not have permissions on that table.
Select statement is:
SELECT * FROM [Prod_Server\Instance].[Database].[dse].[BoxIteration]
Two things to take into account:
add the source server as a linked server in the destination server
verify that the credentials specified while creating the linked server have access to the data in the source server
I have a localized version of SQL Server, so the transalation may not match what you will see in your screen: open Object Explorer window in SSMS, connect to the destination server, open the tree and look for Server Objects, Linked Servers. Right click on the source linked server, and see the properties. Open the Security pane, and see which credentials are used to connect to the linked server.
Once you do so, you have to check the permissions of that credentials on the source server to verify that it can acccess the table in question.
If you don't understand, or can't do some of the steps (for lack of permissions), get help form your DBA: he will understand and solve the problem at once.
If u have access(Having credentials) to both prod and dev Db servers you can use "Import and Export Data"
1.Go to start and open "Import and Export Data"
Wizard will open give source server name, credentials and Database(For your case Prod)
Then give destination server name, credentials and Database(Dev)
Select the table , if there any identity column -->"Edit Mapping" and Enable identity insert.
Then give next--> it will start copying.
Are there known products that can perform schema matching on any level between SQL Server and Oracle as described here? If not a product, would there be a documented methodology on how to perform maybe some semantic search and comparison of db tables, fields, and even data?
I have an existing SQL Server database which currently experiences a lot of trouble updating its data as it uses a lot of undocumented and unreadable legacy code to extract information from various external data sources. Fortunately, there exists an Oracle database that, based on the nature of the business, seems to contain all the information required by the SQL Server DB. The problem is, the schemas between the two environments are vastly different. They don't follow a common naming convention, and may not even follow the same normalization (some tables may be flat on one and normalized on the other).
The naive approach of trying to go through each table and column in SQL Server and then manually and visually searching for possible matches on the Oracle one seems quite impractical, given that there are hundreds of tables between the two databases.
There are commercial solutions(i.e. Database Compare Suite, Cross Database Studio) in the market which can be used to compare both homogeneous and heterogeneous database environments. But it's not good idea to spent money for those tools only for the schema comparison.
There might be several methods/tools/solutions which has certain limitations based on their scope. I am giving solution to compare schema matching between SQL Server and Oracle. Level of matching like table contents and data structure depends on your level of implementation.
In my Approach, suggesting following steps to full fill your requirements:
Establish SQL Server link server to Oracle Database. Steps are mentioned in the reply trail.
Now, access SQL Server and Oracle tables directly from SQL Server environment itself. It's feasible to compare table data using following approach:
SQL Server :
select field1, field2, field_N from openquery(DEV, 'select * from oracle_owner_schema.testtable')
minus
select field1, field2, field_N from sqlserver_database.schema_name.testtable
3 You can compare data structure(field length, data type, default value, etc.) by using dictionary table from SQL Server and Oracle in a same way.
Establish SQL Server link server to Oracle Database
Setup ODAC
Copy missing DLLs from instaclient to c:\oracle\product...\client_1\BIN [Location in which ODAC was installed.]
Add hostname, portnumber, and service name in c:\oracle\product...\client_1\network\admin\tnsnames.ora, sample:
LOCALSERVER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP_Hostname_Oracle_Server)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
Configuration in the SQL Server:
a. Connect to SQL server
b. Database>Server Objects>link servers>providers>OraOLEDB.Oracle>Right
c. Click>Properties>"Check Enable for 'Allow Inprocess'", then Save it.
d. Database>Server Objects>link servers>Right Click>New Link Server>
**************General TAB*************************
Linked server: Any Name for link server in MSSQL
Provide name: Oracle Provider
Product Name: Oracle
Datasource: Provide name which you have added in tnsnames.ora
****************Security TAB***************************
Choose "Be made using this security contest:"
Remote login: username for remote database <<e.g. guest >>
With password: password <<e.g. guest>>
How to use:
select * from openquery(Linked_server_Name, 'select * from schema_name.table_name');
i.e. select * from openquery(Any Name_for_link_server_in_MSSQL, 'select * from oracle_owner_schema.testtable');
Note: Version of ODAC and oracle client should be same.
I have been trying for the past week or so to import data programmatically to a SQL Server 2008 table from a Microsoft Access .mdb file. I have been getting nothing but errors, and solving one just reveals another. I made the file into a linked server, and now when I try to query it with:
Select * from OPENQUERY(Importdata, 'Select * from [IMBPieceBC]')
I get the error:
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "Importdata" returned message "Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "Importdata".
I've read several suggestions to relink dlls in the registry, but I've done that, and I'm still getting the error. Is there anything else I can do to fix it, or at least figure out what is wrong?
Migrating the data to a SQL Server instance is not an option. The mdb files are generated by a third-party program, so there's nothing we can do about it.
I have a similar situation at my workplace - a third party application that maintains data in MDBs, but other applications needing access to it. How I've done it is that this 'intermediary' application has links to the SQL Server tables and the MDB tables. You could use either a query or a VBA written form event to transfer information from the MDB table(s) involved into your corresponding SQL Server tables using a INSERT INTO query, fitted with a SELECT FROM subquery providing the values being inserted.