SQL Server not configured for data access - sql

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.

Related

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 :-)

SQL Linked server - Remote access error when executing SP

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.

Access another SQL Server through stored procedure

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.

Create a linked server on a remote server ? SQL Server 2008

I'm trying to create a linked server on a remote server. I know how to create it on the same server that I run the script in .
EXEC master.dbo.sp_addlinkedserver #server = #name, #srvproduct=N'oracle', #provider=N'MSDAORA', #datasrc= #sursadate
EXEC master.dbo.sp_addlinkedsrvlogin #rmtsrvname=#nume,#useself=N'False',#locallogin=NULL,#rmtuser=#username,#rmtpassword=#password
but how can I define that I want the linked server to be created on another server also using a script that I run it on the server I am on (not the same one that i want the linked server to be created on)? Is there a way to define an ip adress to where it should be created?
To be more clear for example: I'm running a script on a server 0.0.0.1, but I want the linked server to be created on another server 0.0.0.2
Unless you already created db server 0.0.0.2 as linked server into 0.0.0.1
then you only you can run this on 0.0.0.1.
EXEC [linked_server_name_for_0.0.0.2].master.dbo.sp_addlinkedserver #server = #name, #srvproduct=N'oracle', #provider=N'MSDAORA', #datasrc= #sursadate
EXEC [linked_server_name_for_0.0.0.2].master.dbo.sp_addlinkedsrvlogin #rmtsrvname=#nume,#useself=N'False',#locallogin=NULL,#rmtuser=#username,#rmtpassword=#password

How to create Linked Server with non-default port

I want to create a Linked Server in MS SQL Server 2000 to a MS SQL 2005 Server which runs on port x (not the default port 1433). But it doesn't work, as I can't specify the port anywhere!?
Using sqlcmd (specifying port x), I can connect to the server without problems - but I can't set it up as a Linked Server.
How can this be done?
Another way to achieve this (assuming that you have set up 8080 in SQL Server) is with the following code:
EXEC sp_addlinkedserver 'myserver', '', 'SQLNCLI', 'xx.xx.xx.xx,8080'
EXEC sp_addlinkedsrvlogin 'myserver', 'FALSE', NULL, 'user', 'pwd'
In the new linked server dialog, choose "Other data source", select "Microsoft OLE DB Provider for SQL Server" as your provider name, then use this as your provider string:
Data Source=192.168.1.100,1433;Network Library=DBMSSOCN;Initial Catalog=yourdbname;User ID=username;Password=password;
Replace the IP and "1433" with your IP and port number.
More info on connection strings: http://support.microsoft.com/kb/238949
Based on Shane's suggestion, adding an alias worked for me.
(SQL Server 2008 R2):
Open SQL Server Configuration Manager
Expand "SQL Server Configuration Manager (local)"
Expand "SQL Native Client 10.0 Configuration (32bit)"
Click "Aliases"
Right-click in the right-side alias list, and choose "New Alias"
"Alias Name" is whatever you want to reference the linked server as.
"Port No" is your non-default port.
"Protocol" depends, but you can most likely leave this as "TCP/IP".
"Server" is the address of the server you're trying to connect to (not including port).
(repeat the steps for "SQL Native Client 10.0 Configuration" (minus the '32bit' text))
Adding an alias this way allowed me to add a linked server with the Server Type as "SQL Server", without configuring provider options, etc.
Note that 4-part queries will look similar to this:
SELECT * FROM [SQLSERVER,14333].[DATABASE].[dbo].[Table1]
I had to do this today as well (add a linked server with non-default port). In my case it was adding a SQL Server 2014 linked server to a SQL Server 2016.
Steps using SQL Server Management Studio:
Open SSMS and go to Server Objects > Linked Server > New Linked Server
Use this format for the Linked Server
ip-address-of-linked-server\instance-name,non-default-port or, 192.168.10.5\dev-sql,25250. Instance name is required only if that instance is not the default instance on target linked server. Also, you can replace ip address by host name if the linked server is on your local network.
Select SQL Server for Server Type
Add any credentials required to connect using the Security tab
Query the new server using the format just like SQLDBA specified above.
Same thing using T-SQL:
EXEC master.dbo.sp_addlinkedserver #server = N'192.168.10.5\dev-sql,25250', #srvproduct=N'SQL Server'
EXEC master.dbo.sp_addlinkedsrvlogin #rmtsrvname=N'192.168.10.5\dev-sql,25250',#useself=N'False',#locallogin=NULL,#rmtuser=N'my_username',#rmtpassword='my_pswd'