I have two databases, on two different servers, with different credentials to access them.
I need to call a stored procedure in the second database from within the context of the first database. However, for security purposes, the Users are not common between the two databases.
When I call:
DECLARE @OtherServer varchar(100) = 'MySecondServer'
DECLARE @OtherDatabase varchar(100) = 'MySecondDatabase'
DECLARE @sql nvarchar(4000) = N'SELECT * FROM ['+@OtherServer +'].['+@OtherDatabase +'].dbo.Customer_Info'
EXEC sp_executesql @sql
How do I specify what User name and Password to pass, if it isn't identical to how I'm connected to the first database?