SQL Linked server - Remote access error when executing SP - sql

I've set up a linked server between an instance on SQL 2012 and SQL 2008R2 but
I keep getting the below error when trying to execute a stored procedure on a remote server:
Msg 7201, Level 17, State 4, Line 1
Could not execute procedure on remote server 'TEST' because SQL Server is not configured for remote access. Ask your system administrator to reconfigure SQL Server to allow remote access.
I've checked on both servers and they're configured to allow remote connections. The login that I've used has sysadmin access on the remote server and I can see all the databases when I expand 'Catalogs' within the linked server. When I test the connection this also says it's connected successfully. The SQL Service account also has SA on both instances for what it's worth
The odd thing is when I run a simple select query on one of the tables within the database it shows a result but it doesn't seem to like the SP.
Select * from Linkserver.database.dbo.table
The above works fine but this SP doesn't:
EXECUTE Linkedserver.database.[dbo].[SP] ....
Any recommendation would be appreciated.

Despite being an old thread, forget about enabling remote access (and restart service) on remote server and try:
EXECUTE (N'database.[dbo].[SP]') AT Linkedserver

If you want to run SPs from Server B, then make Server B as the linked server in server A.
Run the script below in Server A, not B:
EXEC sp_configure 'remote access', 1; RECONFIGURE;
Then restart SQL Service in A.
Done.

Please first check your server properties if remote connections is allowed (related picture below). IF yes, use: exec nameofyourSP 'remote access', 1 reconfigure and try again.

First Run:
EXEC sp_configure 'remote access', '1';
RECONFIGURE;
You now need to restart MSSQLSERVER in order for the sp_configure command to take effect.
Once you restart it, run sp_configure again and notice that the run_value is 1 now. That's what you want.

Related

SQL Server 2014 can't login after detach database

I'm using using Windows server and I'm having trouble logging in to SQL Server 2014.
A few days ago I changed default user from master database to new one. But today I opened SQL Server Management Studio.
I detach that database by right-clicking on it. After that, I disconnect from SQL Server Management Studio and then connect again.
Check: Windows authentication
Click OK
I get an error:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (.Net SqlClient Data Provider) error:233
When I try more to fixed it, now I get this error:
Login Failed for user A. Reason: Server is in single user mode. Only one administrator can connect at this time (Microsoft SQL Server, Error: 18461)
What causes this error and how do I login again and attach my database?
Can I login to master database?
One way to solve this is by starting SQL instance in minimum config mode.
NET START MSSQLSERVER /f
Once you connect to the instance from same cmd window, then change the Max memory setting :
SQLCMD -S <ServerName>\<InstanceName> -E
A prompt occurs:
1>
Type the following:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 4096;
GO
RECONFIGURE;
GO
Restart the instance from Configuration Manager.
More on sqlcmd here:
https://learn.microsoft.com/mt-mt/sql/ssms/scripting/sqlcmd-use-the-utility?view=sql-server-2017

How to connect AWS sql server by sql server express

We have created SQL server database using RDS AWS console. With following configurations:
Availability zone
ap-south-1b
VPC
vpc-07b03fb50131ed688
Subnet group
default-vpc-07b03fb50131ed688
Subnets
subnet-01ea3ba2b300b123d
subnet-019551993b22cc459
Security groups
rds-launch-wizard-1 (sg-08ceba391dda818db)
( active )
Publicly accessible
Yes
But we are not able to connect it with SQL express with local machine. Any help to update security options..
Good day,
Not sure what you mean by connect it with SQL express. My feeling is that you confuse two unrelated application: (1) SQL Server Express and (2) SQL Server Management Studio (SSMS). With that being said, it is possible that you meant to connect from one server to the other using linked server for example. I will answer both options...
Connecting from SSMS to AWS SQL Server
This is well documented in the official AWS system as you can see here. Basically you need to copy your server endpoint from your account.
If this is what you meant so you must understand that SSMS is a client application and had nothing to do with SQL Server (meaning it is not part of SQL Server but totally separate application, which can be install with or without SQL Server like any unrelated app)
Create linked server from local server to AWS SQL Server
If you do mean to connect using linked server from one server to the other, then:
Step 1: Do the same as above option and get the information to connect from SSMS. We need the Server name, user name, and password.
Step 2: Confirm that you can connect from SSMS first.
Step 3: continue to create linked server, and map your remote username to the local server. For this you can use the bellow queries.
USE [master]
GO
-- create linked server to the remote server
EXEC master.dbo.sp_addlinkedserver
#server = N'<Your Server name come here>', -- this is the same information as you use from SSMS
#srvproduct=N'SQL Server';
GO
-- check your list of servers to confirm that you see the new one
select * from sys.servers
GO
-- Now we need to map your remote login to your new linked server
EXEC master.dbo.sp_addlinkedsrvlogin
#rmtsrvname = N'<Your Server name come here>',
#useself = 'FALSE',
#locallogin = NULL ,
#rmtuser = N'RonenAriely', -- enter your remote user name
#rmtpassword = '<Enter Your remote Password here>'
GO
-- that's it, wee can query the remote server from the local server now
--check that your can execute remote query
SELECT name FROM [<Your Server name come here>].master.sys.databases
GO
I hope this solve your issue :-)

How to access Database from other computer using sql query in sql server

I am using a SQL database residing on my local computer. I want to access a table from a database residing on another computer using SQL query.
I have been able to connect the remote database with my database and all its tables are shown in Enterprise manager on my local machine. I have added remote SQL Server in my local SQL Server.
When I use select statement in my local SQL server it gives the message database does not exist or access denied.
Any help in this would highly be appreciated.
EDITED
Select * from [ServerName].DatabaseName.dbo.tableName
Use OPENROWSET
Example
SELECT t.version FROM
OPENROWSET('SQLNCLI', 'server=Myserver;UID=xxxx;pwd=yyyy',
'select ##version version') t
Note:
SQLNCLI is the name of installed OLE DB provider
Datasource: {server=Myserver;UID=xxx;pwd=yyy}
You have to enable OPENROWSET by executing the following script:
sp_configure 'show advanced options', 1
reconfigure
go
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
OPENROWSET is like connecting to a linked server

Is there a way to find what accounts can execute xp_cmdshell?

I'd like to find out what users on a SQL Server system can execute xp_cmdshell. Is there a query that will do this?
I'd like to know how to do it for SQL Server 2000 - 2008
Googling "xp_cmdshell":
When first enabled, xp_cmdshell requires CONTROL SERVER
permission to execute and the Windows process created by
xp_cmdshell has the same security context as the SQL Server
service account.
http://msdn.microsoft.com/en-us/library/ms175046.aspx

SQL Server not configured for data access

I'm running a SQL Server 2005 database from a VB 6 Application. I connect to the database
through an ODBC DSN.
I renamed the computer on which I'm running the default instance of SQL server from 'Software' to 'IT'. I then ran the sp_dropserver and sp_addserver stored procedures to rename the instance.
On restarting the SQL Server service, the server was able to pick up on the new SQL Server name.
After configuring the ODBC data source name to the new name, the connection was Ok. I'm able to run my application and read records through ADO record sets. However I'm unable to update any recordset using the .Update method. I get the following error instead ... SQL Server not configured for data access
How can I enable data access on the renamed server instance?
How to: Rename a Computer that Hosts a Stand-Alone Instance of SQL Server 2005
You should be able to run this but not against any linked server. It's not a linked server. It's local.
EXEC sp_serveroption 'YourServer', 'DATA ACCESS', TRUE
Just go to the linked server properties > Server options > Data access --> true
Works on SQL Server 2014.
Regards
I just would like to add to the previous answers that, at least in my case here, I needed to enable data access in both places.
for instance:
there is server A and server B
On server A
I have a linked server LB that links me from server A to server B
I need to execute the following:
-- on server A
exec sp_serveroption 'LB', 'data access', 'true'
-- on server B
exec sp_serveroption 'B', 'data access', 'true'
with this
use master
go
exec sp_serveroption 'server name', 'data access', 'true'
go
linked servers generated for replication still showing same error
I've just come across this error and found that it was caused by me trying to run OpenQuery against the local server (doh!). Changing the server name to that of an actual linked server resolved my issue.