Access another SQL Server through stored procedure - sql

I want to access another SQL Server to import and update data of that server's database through a stored procedure.
For that I created linked server using sp_addlinkedserver.
EXEC sp_addlinkedserver
#server = N'LINKEDSERVER'
,#srvproduct=N''
,#provider=N'SQLOLEDB'
,#datasrc=N'[DB-Instance.cuprxxxlj.ap-xxxxxxx-x.rds.amazonaws.com]';
Then try to access by SQL query
SELECT *
FROM [LINKEDSERVER].[DATABASE].[dbo].[TABLE]
And getting errors like
OLE DB provider "SQLNCLI11" for linked server "LINKEDSERVER" returned message "Login timeout expired".
OLE DB provider "SQLNCLI11" for linked server "LINKEDSERVER" 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 had created database instance on amazon server and another is also on the amazon server and both are publicly accessible but don't know why I'm getting Server is not found or not accessible. Am I missing any server site setting or something else?
Please guide me if I am going in wrong direction.

I found the answer. The problem was an instance, I had created "Amazon RDS for SQL Server" which is currently not supporting to "Linked servers".
So I create a new AWS EC2 instance for Windows Server 2012 R2 and then I create Linked servers in it and tried to assess remotely. Now its working fine as I wanted.
Here is detailed document to Running SQL Server Linked Servers on AWS
Thanks.

Maybe try changing the timeout settings?
sp_configure 'remote query timeout', 0
go
reconfigure with override
go

This article explains in detail how to link one AWS Sql Server to another (https://aws.amazon.com/blogs/apn/running-sql-server-linked-servers-on-aws/). I am not certain what is wrong in your case, but this has a lot of steps that I do not see in your description.
And the one thing that does jump out at me is that you haven't configured any login security/access control. So unless the target server is open to the world, I would guess that you have to add that as a minimum.

Related

Error when creating linked server in SQL Server 2008R2

When I create a linked server in SQL Server, it causes an error
Cannot create a instance of OLEDB provider SQLNCLI10 for linked server 'linked server name '(microsoft sql server error 7302)
How can I rectify this error?
The OLEDB provider may not properly installed. What you chose is the SQL Server native client. Do you have SSMS installed on server? This should come with sql native client OLE DB.
I would like to share an experience when I faced following error
Cannot create an instance of OLE DB provider "xxx.YYYY" for linked server "test". Error 7302.
I observed this message from a failed SQL Server job. On analysis it is found that Allow Inprocess was not enabled for the provider. When this is enabled, everything worked fine for me.
Server Objects --> Linked Servers --> Providers
Also refer following
"Cannot create an instance of OLE DB provider" error as Windows Authentication user
Linked Server Properties (Provider Options Page)
Configuring OLE DB Providers for Distributed Queries

Unable to connect to Azure database from SQL Management Studio

When i am trying to connect to the Azure DB from SQL Management studio an getting teh below error. Not sure why am getting this error as i was able to acess the DB erlier from SQL Management Studio.
Need help on this.
TITLE: Connect to Server
Cannot connect to ijk3ffy48i.database.windows.net.
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476
BUTTONS:
OK
I think probably you haven't configure any Azure DB firewall rules to allow your computer's IP to communicate with your Azure DBs.
Simple things to check (not sure what you've tried so humour me here):
You're connected to the outside network.
Instance\Database name, username and password are correct.
Instance and database are online and connectable (Azure servers not down for scheduled maintenance or run out of paid services.)
Firewall rules are incorrect.
Also I think this question here is identical to your question. Try checking that out.

how to take sql backup without login

I need some help as I am unable to log into a database.
Some Error is coming like...
unable to start service MS SQL SERVER ON SERVER SERVER.(MSCORLIB)
A network-related or instance-specific error occurred while establishing a connection to sql server.
The server was not found or was not accessible. verify that the instance name is correct and that sql server is configured to allow remote connections.(provider: name pipes provider, error 40 could not open a connection to sql server) (Microsoft sql server, error :2)
My question is how can I take the backup now because I am unable to login into the sql.
As you have event in 9003 in your Event Log it indicates that you have corrupted master datatbase and you will need to rebuild it.
First check your disks for errors and fix them.
Then you will need to rebuild the master database:
For SQL Server 2005 check this:
http://www.sqlcoffee.com/Troubleshooting007.htm
or
http://thedbavault.blogspot.cz/2013/01/ms-sql-server-2005-rebuild-master.html
Also some recommend to use database file from another instance of the same version of SQL Server.
http://blogs.technet.com/b/fort_sql/archive/2011/02/01/the-easiest-way-to-rebuild-the-sql-server-master-database.aspx
Then you should be able to restore non-corrupted backup copy of your master database.
If you do not have backup of your master database, then you will have to recreate all logins, users, roles, permissions etc.
To backup data without running SQL Server you can only backup database files .mdf, .ldf.

Cannot login to sql server 2008 R2 after rebooting server

I am using Windows-server-2008 with Microsoft SQL Server 2008.
And there are a lot of questions about this, but nothing on the internet solved it.
The problem is that i can't connect to the my SQL Server 2008 R2 after rebooting my server.
I placed some new memory in my server, and after rebooting my client/server application didn't work anymore because it cannot reach the database.
So i tried to get in SQL Server Management Studio (SSMS), and tried to loggin with Administrator and another user but both do not work.
When i logg in the following message is displayed:
Cannot connect to (local)
A network-related or instance-specific error occurred while establishing a connection
to SQL Server. The server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(Microsoft SQL Server, Error: 2)
I Tried a lot of different things like:
Rebooting server
Try to start the server manually from Sql Server Configuration Manager
Named Pipes - Enabled
TCP/IP - Enabled
Tried to create an new system user or database user as described in the following article: Click Here
Can somebody please help me? I am really confused because i need to get this online. Otherwise i have to reinstall the database server but i do not have a back-up. (is there some folder with a back-up of the settings/tables/columns are stored and can be imported from reinstall?
I was having the exact same problem. net start mssqlserver was giving me the blurb about a failed login attempt. The problem was that I had recently changed the password for the administrator account, and the new password didn't get updated in services.
Here's how I fixed it:
First locate SQL Server from the list here:
Right click and select properties, and navigate to the Log On tab:
Then I typed the new password, and like magic I was able to start SQL Server right through the services manager.
I also did this for any other processes which were marked as "stopped" even though Startup Type was marked as "automatic" (namely, SQL Server Agent).
Is it a named instance or default? Also, is this a local instance? (I see the "(local)" but just wanted to make sure.)
Start the sql server services from services.msc and try to connect

SQL Server 2005 Express - could not open a connection

I installed Microsoft SQL Server 2005 Express edition on my Vista Ultimate computer. However, when it opens I enter my computer name / SQLEXPRESS. When I click the Connect button, it gives me an error message.
Under the configuration tools I cannot find the SQL Server Surface Area Configuration. It only has SQL Server Error and Usage Reporting.
The error message I receive when I click the Connect button is:
A network related or instance specific error occurred while establsihing a connection to SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that the SQL server is confugured to allow remote connection (provider: Named Pipes Provider, error 40- Could not open a connection to SQL Server) (Microsoft SQL Server : error 67)
From your question, as you'd written, it appears the slash is incorrect. Try:
.\SQLEXPRESS
Also ensure that your SQL Server services are started. Run services.msc and find SQL Server(SQLExpress).
Another thing to check for is the account that the SQL Express service is running under. I think it defaults to network service, but I typically run it under Local System (or if you're feeling ambitious, make a service account for it). This has taken care of a handful of permission issues I've had with SQL Express in the past.