Hi All I am trying to create a View from another database server...
I have have got server A an din Server A is where i want to create a view referencing a table from Server B.... when I run the command below:
create view TableFromServerB as select * from ServerB.master.information_schema.table;
I get the following error:
OLE DB provider "SQLNCLI11" for linked server "ServerB" returned
message "Login timeout expired". OLE DB provider "SQLNCLI11" for
linked server "ServerB" returned message "A network-related or
instance-specific error has occurred while establishing a connection
to SQL Server. Server is not found or not accessible. Check if
instance name is correct and if SQL Server is configured to allow
remote connections. For more information see SQL Server Books
Online.". Msg 53, Level 16, State 1, Line 0 Named Pipes Provider:
Could not open a connection to SQL Server [53].
I have done some research online and i came to a source that suggested using sp_addlinkedserver in my command .. which i have done and when i did this it said server already exists . So is there anything i am missing out here??
I have seen an issue like this before:
Can you please do something like this:
Create a view in your linked server to access the object i.e master.information_schema.table;
Use this view in the queries from the server where you want to display the results.
Eg:
--- create view script--
create view dbo.vINFORMATION_SCHEMATABLES
as
SELECT *
FROM INFORMATION_SCHEMA.TABLES
go
-- select statement from local server
select * from [testSRV].[testDB_far].[dbo].[vINFORMATION_SCHEMATABLES]
Let me know if this helps.
Related
Context: I'm trying to use SQL Server's Polybase to query data in parquet files. One of the steps required to do so is to create an external file format that maps to parquet. MSDN provides SQL sample below.
CREATE EXTERNAL FILE FORMAT parquet_file_format
WITH (
FORMAT_TYPE = PARQUET,
--DATA_COMPRESSION = 'org.apache.hadoop.io.compress.SnappyCodec'
DATA_COMPRESSION = 'org.apache.hadoop.io.compress.GzipCodec'
);
When I execute it I get the following error.
OLE DB provider "MSOLEDBSQL" for linked server "(null)" returned message "Login timeout expired".
OLE DB provider "MSOLEDBSQL" for linked server "(null)" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
Msg 10061, Level 16, State 1, Line 40
TCP Provider: No connection could be made because the target machine actively refused it.
I've tried enabling TCP network protocol
and also tried configuring the remote access server configuration option neither of which resolve the error.
EXEC sp_configure 'remote access', 0 ;
GO
RECONFIGURE ;
GO
Question: Can someone please point me in the right direction, or tell me what I'm doing wrong?
Turns out issue was Polybase services weren't running. I was able to run them in the sql server configuraion manager under sql server network configuration. This was helpful: https://www.sqlservercentral.com/forums/topic/polybase-syntax-error
I want to pull out data from different tables from different servers. I took a query at V5\SQL2014 Server and run these following to connect to V5_27\SQL2005 Server
EXEC sp_addlinkedserver
#server= 'V5_27\SQL2005',
#srvproduct='V5_27\SQL2005',
#provider='SQLNCLI',
#datasrc='tcp:0.0.0.0'
EXEC sp_addlinkedsrvlogin
#useself='FALSE',
#rmtsrvname='V5_27\SQL2005',
#rmtuser='sa',
#rmtpassword='123'
SELECT * FROM Stk006,[V5_27\SQL2005]..[TESTACC].Stk006
It shows me following errors.
OLE DB provider "SQLNCLI11" for linked server "V5_27\SQL2005" returned message "Login timeout expired".
OLE DB provider "SQLNCLI11" for linked server "V5_27\SQL2005" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
Msg 10049, Level 16, State 1, Line 22
TCP Provider: The requested address is not valid in its context.
User and Password are not wrong.
Allow remote is enabled in both servers.
TCP/IP and Named Pipes are enabled in both servers.
Please help me, thanks!
Thanks everyone, I found a solution for my problem.
You can check the solution link here or do below steps.
Try to create a linkServer , Object Explorer -> Server Objects -> Linked Servers (Right click and create new)
Configure Settings
Enter your Server Name
Login with sa and password
Then Test Connection of it.
Enjoy your query.
select
lc.t2 as 'Local Stock Code',
ext.t2 as 'External Stock Code'
from
Stk001 lc,
[V5_27\SQL2005].[TESTACC].[dbo].[STK001] ext
I had configured a linked server to enable the SQL Server Database Engine to execute commands against OLE DB data sources outside of the instance of SQL server by executing sp_addlinkedserver procedure. After doing that I was trying to execute a procedure on a linked server using the following statement
EXEC [LinkedServer].[DatabaseName].[DatabaseOwner].[StoredProcedure] param1, param2
When I tried to execute the statement mentioned above it threw me the following error
OLE DB provider "SQLNCLI10" for linked server "server name" returned message "Unable to complete login process due to delay in opening server connection".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "SQLNCLI10" for linked server "server name".
I tried the following
Check if a linked server has remote access enabled
Increase remote query timeout
Check firewall to see if port was enabled.
What am I missing here? I appreciate your help.
I am developping some code that transfers data between SQL servers. In this phase, all my work is on the same server (local, where I am the owner), but I am already trying to implement the OPENROWSET functionnalities that will be used at production time (where data will be on different servers and where I will have to build queries for the transfers). The following 3 codes are supposed to do the very same thing, but the one making use of OPENROWSET is giving me an error ... Bref, I am stuck! if anyone could help...
3 parts naming: works
USE db1
SELECT * INTO dbo.myTable FROM db2.dbo.myTable
OPENDATASOURCE: works
USE db1
SELECT * INTO dbo.myTable FROM OPENDATASOURCE
('SQLOLEDB',
'Data Source=127.0.0.1\SQLEXPRESS;Integrated Security=SSPI'
).db2.dbo.myTable
OPENROWSET: does not work
USE db1
SELECT * INTO dbo.myTable FROM OPENROWSET
('SQLOLEDB',
'Trusted_Connection=yes;Server=(Local)',
'db2.dbo.myTable')
Where I am getting the following message:
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Login timeout expired".
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.".
Of course I have tried to use the standard properties of my connection string (as with OPENDATASOURCE) but I was also getting the following error:
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Invalid authorization specification".
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Invalid connection string attribute".
For one thing: Your OPENROWSET statement isn't specifying the server instance.
Try
USE db1
SELECT * INTO dbo.myTable FROM OPENROWSET
('SQLOLEDB',
'Trusted_Connection=yes;Server=127.0.0.1\SQLEXPRESS',
'db2.dbo.myTable')
Wow i was just playing around with sp_addlinkedserver and i accidentally ran this command: sp_addlinkedserver abc,'SQL Server'
1) i had command(s) completed successfully.. but what happened?
2) how do i undo what i did?
You created a link to a server named abc.
You could try to query the server across this link using a command such as:
select *
from abc.master.information_schema.tables
But (unless you really do have a server called abc) it'll return you a message similar to:
OLE DB provider "SQLNCLI10" for linked server "abc" returned message
"A network-related or instance-specific error has occurred while
establishing a connection to SQL Server. Server is not found or not
accessible. Check if instance name is correct and if SQL Server is
configured to allow remote connections. For more information see SQL
Server Books Online.".
You can view your linked server in SSMS under Server Objects>>Linked Servers in the Object Explorer.
To get rid of the linked server, use the following statement:
sp_dropserver abc
You now have a linked server called abc
To remove, use sp_dropserver (There is no sp_droplinkedserver). Thus:
EXEC sp_dropserver 'abc', 'droplogins'
You added the Linked Server, see here about using it. Briefly, Linked servers used to obtain the ability to make distributed queries between your and linked servers:
SELECT MyServer.MyDatabase.dbo.Table1.Field1,
LinkedServer.MyDatabase.dbo.Table2.Field2
FROM MyServer.MyDatabase.dbo.Table1
INNER JOIN LinkedServer.MyDatabase.dbo.Table2
ON MyServer.MyDatabase.dbo.Table1.ID=LinkedServer.MyDatabase.dbo.Table2.ID