Sql ошибка 7416

  • Remove From My Forums
  • Question

  • I am trying to use a linked server and it works as long as I do not specify the sp_addlinkedserver @provstr parameter. If I specify that parameter I always get a 7416 «Access to the remote server is denied because no login-mapping exists» error. I have tried adding the logins various ways but it’s very specific to the @provstr parameter, and it doesn’t even matter what I put in that parameter. As soon as I put something in there whether it is valid or invalid, I get the error.

    Anyone else seen this? There is an amazing lack of any discussion about the error when I search for it.

    If I do this it works fine,

     EXEC sp_addlinkedserver @server= ‘linkedname’, @srvproduct=», @provider=’SQLNCLI’, @datasrc=’servername’, @catalog=’mydatabase’
    EXEC sp_addlinkedsrvlogin ‘linkedname’, ‘true’, ‘AppUser’

    But as soon as I add the @provstr parameter, then I get the error if I try to use linkedserver,

    EXEC sp_addlinkedserver @server= ‘linkedname’, @srvproduct=», @provider=’SQLNCLI’, @datasrc=’servername’, @catalog=’mydatabase’, @provstr=’Failover Partner=otherservername’
    EXEC sp_addlinkedsrvlogin @rmtsrvname=’linkedname’, @useself=’true’, @locallogin=’AppUser’

    It doesn’t even make any difference what I put in the @provstr parameter — the sp_addlinkedserver statement always executes without an error, but running a query that uses the linked server generates the error.

  • Remove From My Forums
  • Вопрос

  • We have stored procedures that call views that use link server connections to another database. On one system there is no problem using the views and everything is happy. However, when the same routines are run on a different SQL Server that is using an
    alias for the linked server name, the views fail with an error 7416. However, doing a direct query to the same table using the same fully qualified name as the view works fine.

    Why would a view fail but not a direct query call? 

    Thanks


    Lou Davis Software Engineer E2B Teknologies

In this blog, we are going to discuss an error that we have recently encountered while using a linked server. Moreover, we will discuss fixing Linked Server ERROR 7416 – Access Denied as No Login-Mapping Exists.

What do we understand by SQL Server?

SQL Server is a Relational Database Management System by Microsoft. It is used as a central location to save and get the data needed for applications.  This product is made for the basic function of storing recovering data as required by other applications. It can be run either on the same system or on another across a network.

There are different flavors of SQL Server, which offer various features as per user requirements. These products, also called Editions, include:

  1.     Enterprise: Usually  Built for large organizations with complicated data requirements.
  2.      Standard: It is helpful for departments within organizations.
  3.      Workgroup: This usually Includes a reporting module for synchronizing data remotely.
  4.      Developer: This is Single-use installation, meant for development and testing of applications
  5.      Web: This is usually for  small businesses looking to build web applications
  6.      Express: This is a  free edition meant for learning and education
  7.     Compact: Another free option which is suitable for stand-alone applications
  8.     Evaluation: This is a Trial version that is only valid for a short time period

Remote Server

A remote access server (RAS) is a type of server that gives a suite of services to remotely connected users over a network or the Internet. Remote server functions as a remote gateway or central server that connects distant users with an organization’s internal local area network (LAN).

A RAS contains specialized server software which is used for distant connectivity. This software is developed to provide authentication, connectivity, and resource access services to connecting users.

A RAS is installed within an organization and directly linked with the organization’s internal network and systems. Once linked with a RAS, a user can fetch his or her data, desktop, application, print and/or other supported services.

SQL Server Management Studio

SQL Server Management Studio permits you to generate and control your databases as well as administer your SQL Server configuration.

Tasks you can perform with SSMS include:

  • Generate, modify & delete databases and database objects such as tables, views, stored procedures etc
  • Query your databases
  • Generate  and maintain user accounts and roles
  • Generate and maintain backups (either manual or scheduled)
  • Allows to import and export data from/to other databases
  • Allows to replicate databases across multiple machines

SSMS permits you to do most tasks either systematically or via the GUI. For example, you can generate a database by right-clicking and selecting New Database, or you can run a SQL script to generate it by clicking. If you face any SQL related problem, you can see Limitations of Memory-Optimized tables in SQL Server.

Receiving Linked Server ERROR 7416 – Access Denied as No Login-Mapping Exists

While dealing with security and after altering some level of access and permission of some logins, we have received an error message while accessing data through linked servers with some logins which was working earlier. Here is the text of the error message.

Msg 7416, Level 16, State 2, Procedure usp_fetch_data, Line 5 [Batch Start Line 10] Access to the remote server is denied because no login-mapping exists.

Reasons for Linked Server ERROR 7416 – Access Denied as No Login-Mapping Exists

Error 7416 Access To The Remote Server Is Denied and other critical errors can appear when your Windows operating system becomes corrupted. Opening programs will be slower and response time will be delayed. When you have several applications running, you may observe crashes and freezes. There may be several reasons for this error including unrestricted startup entries, registry mistakes, hardware decline, shattered files, needless program installations, and so on.

How are we supposed to Fix Linked Server ERROR 7416 – Access Denied as No Login-Mapping Exists?

Finally, we were able to find the solution to this error. We have made a few changes in the linked server and used the following script to fix this error. We have added a login to the linked server which has an issue accessing it. Below is the following script and you just need to change your username in place of ‘myUser’ and the appropriate server\instance name.

Use master

GO


EXEC master.dbo.sp_addlinkedserver 


 @server = N'LinkedServerName', 


 @provider=N'SQLNCLI',


 @srvproduct = 'MS SQL Server', 


 @provstr=N'SERVER=ServerName\InstanceName;User ID=myUser'


EXEC master.dbo.sp_addlinkedsrvlogin 


 @rmtsrvname = N'LinkedServerName', 


 @locallogin = NULL , 


 @useself = N'False', 


 @rmtuser = N'myUser', 


 @rmtpassword = N'*****'


GO

 

Conclusion

Here, we have briefed about the Linked Server Error 7416 of the SQL database. Users can get familiar with this error and why it pops up by going through the blog. It proves to be difficult to understand for novice users, so we have provided the basic illustrations of the error. Moreover, you can utilize the correct script mentioned in the blog to fix the error in no time.

You May Also Read: SQL Error 17204

Related Post

I have a local SQL Server 2008R2. I have configured Linked Server to a remote database.

The Linked Server works great when I login to the local server using a SQL-login account with sysadmin server role. I can query against the remote server, so I know the Linked Server setting is correct. However, I would get the error below if I use an account that does not have the sysadmin server role.

Msg 7416, Level 16, State 2, Line 2
Access to the remote server is denied because no login-mapping exists.

For both local and remote servers, SQL login is used (Windows authentication is not used)

What kind of security I need to configure for a regular SQL-login account to use Linked Server?

asked Aug 19, 2015 at 0:00

Tony's user avatar

TonyTony

1,8471 gold badge23 silver badges23 bronze badges

4

UPDATE: See @Anton’s and @Wouter’s answer for alternative solution.

According to this blog, I have to specify User ID in the provider string if non-sysadmin accounts are used. Here is an example.

EXEC master.dbo.sp_addlinkedserver 
    @server = N'MyLinkServerName',
    @provider = N'SQLNCLI',
    @srvproduct = 'SQLNCLI',
    @provstr = N'SERVER=MyServerName\MyInstanceName;User ID=myUser'

This exactly matches what I have encountered and it solves my problem.

answered Aug 19, 2015 at 20:51

Tony's user avatar

TonyTony

1,8471 gold badge23 silver badges23 bronze badges

3

As alternative solution you can use the parameter @datasrc instead of @provstr.
@dataSrc works without setting the User ID

Sample:

EXEC master.dbo.sp_addlinkedserver @server = N'LinkServerName', @provider=N'SQLNCLI',@srvproduct = 'MS SQL Server', @datasrc=N'serverName\InstanceName' 
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'LinkServerName', @locallogin = NULL , @useself = N'False', @rmtuser = N'myUser', @rmtpassword = N'*****'

I’ve added a comment here, too, but it’s not visible (don’t know why).

answered Aug 25, 2017 at 12:59

Anton R's user avatar

Anton RAnton R

761 silver badge2 bronze badges

1

After playing around with this, i found that you can avoid having to use the User ID property altogether, by using @datasrc instead of @provstr. This is very poorly documented, but the example below works for me:

EXEC master.dbo.sp_addlinkedserver
    @server = 'SOME_NAME',
    @srvproduct='', -- needs to be explicitly empty, default is NULL and is not allowed
    @datasrc='some_server.com\SOME_INSTANCE',
    @provider='SQLNCLI';

-- Set up the Linked server to pass along login credentials
EXEC master.dbo.sp_addlinkedsrvlogin
    @rmtsrvname='SOME_NAME',
    @useself='true', -- Optional. This is the default
    @locallogin=NULL; -- Optional. This is the default

Using this method you can reuse the same Linked server for all of your users. The currently accepted answer has the huge drawback that you need to set up a separate linked server for each user.

answered Feb 8, 2019 at 15:46

Wouter's user avatar

WouterWouter

1,8293 gold badges28 silver badges34 bronze badges

1

You can also add remote server login mapping by right-clicking on your remote server -> Properties -> Security -> Add

properties

login mappings

answered Mar 4, 2022 at 8:27

Nace Kapus's user avatar

I tried @Wouter ‘s & @anton-r ‘s solutions and neither worked for me, but this did!

This is straight from Pinal Dave’s solution (https://blog.sqlauthority.com/2019/06/07/sql-server-fix-msg-7416-access-to-the-remote-server-is-denied-because-no-login-mapping-exists/)

EXEC master.dbo.sp_addlinkedserver @server = N'mylsname', @srvproduct=N'SQL', @provider=N'SQLNCLI11', @datasrc=N'123.45.6.789', @provstr=N'Encrypt=yes;TrustServerCertificate=yes;User ID=user_no_login'

GO

Interestingly, I do NOT have «user_no_login» on that server — I meant to change it to a user on that machine, but forgot.

Also of note: if you have the IP in the @provstr instead of in @datasrc then while it connects to (local server, maybe?!), it doesn’t connect to the server you’re trying to connect to.

answered Jun 6 at 21:17

mbourgon's user avatar

mbourgonmbourgon

1,2862 gold badges17 silver badges36 bronze badges

Last time I wrote a blog about linked server creation issue. As I said, these are one of the most common issues. But as soon as such blogs get released, I get a number of requests around them immediately. Here is the blog post which is discussing about the linked server error.

SQL SERVER – FIX – Linked Server Error 7399 Invalid authorization specification

After reading that one of the readers contacted me and told that he is getting below error.

SQL SERVER - FIX - Linked Server Error 7416 - Access to the remote server is denied because no login-mapping exists err-7416-01

On first look, I thought this was similar to what was published earlier. But things can surely turn out to be different. Since I had recently blogged about it, I thought to investigate this. To understand more, I looked at the error message in detail. It looks like:

TITLE: Microsoft SQL Server Management Studio
——————————
The linked server has been created but failed a connection test. Do you want to keep the linked server?
——————————
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
Access to the remote server is denied because no login-mapping exists. (Microsoft SQL Server, Error: 7416)
——————————

I played around with the linked server settings on the PC just to realize – I was able to reproduce the error by choosing 1st option in security tab. This was simpler than what I thought.

SQL SERVER - FIX - Linked Server Error 7416 - Access to the remote server is denied because no login-mapping exists err-7416-02

So, I asked him to use either option 2 or option 3. After using right option, the error message disappeared.

Do you remember seeing any such linked server error? Can you share your experience to what happened here this time? Leave a comment as we can learn from each other.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Related Posts

Понравилась статья? Поделить с друзьями:
  • Sql ошибка 5058
  • Sql ошибка 5042
  • Sql ошибка 500
  • Spotify ошибка подключения android auto
  • Sporeapp exe ошибка 0xc000007b