Create a Linked Server Using a Windows Account in SQL Server - sql

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.

Related

Can I link a server that I only have read-access to?

Trying to link a server that I only have read-access to and uses windows authentication to log me in. I'm trying to link it to my local database so I can combine commands in both databases because my web application executes stored procedures.
Is this possible?
https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addlinkedserver-transact-sql?view=sql-server-2017
Yes, you can.
From your description, you want to uses windows authentication to log in the linked server.
When a linked server is created by using sp_addlinkedserver, a default self-mapping is added for all local logins. As a result, if the windows account for the local server also exist in the remote account, you can log in the linked server via the current windows account.
Besides after adding the linked server, you can also create a mapping between a login on the local instance of SQL Server and a security account on a remote server. For detailed information, please refer to the sp_addlinkedsrvlogin (Transact-SQL).

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 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 database on remote server via Linked Server

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;';

How to allow access for a sql server user?

I am a developer-having-to-play-admin and wish to connect to a remote sql server from my development machine using a sql server user ("op_web").
When I try to connect from vs2008 Server Explorer, I can connect to the server, but no databases are listed. If I connect using the server admin user, all databases are listed as expected.
The server is a relatively fresh install made by me.
I have
allowed for remote connections in sql server.
created the login op_web at server level
created a user at database level and assigned to login with same name
assigned roles to the user to allow for reading and writing - I have assigned no schemas and default schema for the user is dbo.
If I log on (locally at server) using sqlserver management studio/sqlserver authentication and the created login, I can display and alter table data as I would expect.
Remote access gives me no choice of databases.
Any pointers to what I might have missed?
You have to give your users rights on the database.