How to connect AWS sql server by sql server express - sql

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

Related

how to create a linked server to a SharePoint site in SQL Server 2014

I keep reading articles online that say this is possible but nothing that says how to do it. I have an SQL Server 2014 server and I want to create a linked server to a SharePoint site. I can go to Server Objects > Linked Server > New but then I don't know what to do.
Follow the steps below:
1.Open SQL Server Management Studio, enter the name of your local SQL Server, and then select Connect.
2.Expand Server Objects, right-click Linked Servers, and then select New Linked Server. To see Server Objects, connect to a local on-premises SQL Server. Then, Server Objects should be displayed.
3.In the Linked server text box, enter the full network name of the SQL Server you want to link to.
4.Under Server type, select SQL Server.
5.In the left pane, select Security. In this step, you map the local account you created to the remote server login.
6.Select Add, and enter the following:
a.Under Local Login, select the local account you created.
b.Check Impersonate if the local login also exists on the remote server.
c.Alternatively, if the local login will be mapped to a remote SQL Server login you, enter the Remote User name and Remote Password for the remote server login.
7.In the left pane, choose Server Options. Set the RPC and RPC Out parameters to True, and then select OK.
Articles:
https://learn.microsoft.com/en-us/biztalk/core/how-to-create-a-linked-server
https://learn.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine
If you want to access SharePoint data from other application, I suggest you use SharePoint API(CSOM(C#), REST API or web service) to achieve it.
Complete basic operations using SharePoint client library code
Complete basic operations using SharePoint REST endpoints

Create a Linked Server Using a Windows Account in SQL Server

There are multiple applications on SQL Server which I am trying to connect to from a Single SQL Server. Instead of creating multiple SQL User ID we thought of creating a single Windows Service Account and use that to connect to other SQL Servers.
The issue is I dont know if I can configure a Linked Server to take the credentials of a Windows Service account.
Points:
Access has been given to the Windows user account
SQL Servers are on Different domains
Is there a best approach to read from multiple sources within the organization other than linked servers?
Update:
Please find below code I am trying to use to create a Linked Server:
USE [master]
GO
EXEC sp_addlinkedserver
#server=N'serverinstance',
#srvproduct=N'',
#provider=N'SQLNCLI',
#datasrc=N'serverinstance.domain.local';
GO
EXEC master.dbo.sp_addlinkedsrvlogin #rmtsrvname = N'serverinstance'
, #useself = N'TRUE'
, #locallogin = N'Domain\NTAccount'
--, #rmtuser = N'user'
--, #rmtpassword = N'pass'
GO
The linked server still fails. I do not want to use any SQL Server User Auth.
I think you need to setup a trust between the 2 domains and make sure the firewall is letting you access the linked server.
It can be either.
https://technet.microsoft.com/en-us/library/ms188477(v=sql.105).aspx
Authentication works the same regardless of if you use Sql or NT Domain authentication.

How to connect to a remote SQL Server using servername, username & password

How to connect to a remote SQL Server using servername, username & password in SQL Server 2005 ?
I'm going to assume that you're talking exactly about what your question asks, how to connect to a remote MSSQL instance inside SQL Server, rather than through SQL Server Management Studio because 1) you don't mention SSMS and 2) it's pretty obvious how to connect with SSMS (I mean, the connect box is right there when you start it).
To connect to one MSSQL instance from another you can use linked servers. You can query data from linked servers, and if they are configured for RPC Out you can also execute SQL against them.
If the server is configured for integrated security, there is no way of doing it without changing the security option.
Check out the ConnectionStrings website - it shows you how to build a connection string that will allow you to connect from your machine to a remote SQL Server instance.
That connection string will typically look something like:
server=YourServerHere;database=YourDatabase;User ID=YourUser;Password=Top$ecret
But there are lots of options and additional things you can specify - the ConnectionStrings.com web site shows and explains them all!

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'

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.