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
Related
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 :-)
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.
I am automating deployments of our admin tools. When a new server is added to our monitoring system I have a trigger that creates a linked server.
I am trying to get my code to create database to work via the linked server from the central server.
Any tip and tricks on accomplishing this task?
Typically, you can't execute DDL against a linked server. There is a trick though. You can call sp_executesql remotely.
You'll need to set the Linked Server's RPC Out property to True before attempting.
EXEC [yourlinkedserver].tempdb.dbo.sp_executesql N'CREATE DATABASE Test;';
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'
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.