Mzsmunna
10/15/2019 - 2:36 PM

SQL Connect to Azure From Local using link

sql connection to azure server db from local sql server db :
-- Make a link to the cloud
EXEC sp_addlinkedserver
  @server=N'MzsAzureDb',
  @srvproduct=N'Azure SQL Db',
  @provider=N'SQLNCLI',
  @datasrc=N'insightm8.database.windows.net,1433',
  @catalog='EnrollmentV2';
GO
--Set up login mapping
EXEC sp_addlinkedsrvlogin
   @rmtsrvname = 'MzsAzureDb',
   @useself = 'FALSE',
   @locallogin=NULL,
   @rmtuser = 'insightm8@insightm8',
   @rmtpassword = 'bdm8#2016'
GO
-- Test the connection
--sp_testlinkedserver MzsAzureDb;
--GO
select * from [MzsAzureDb].[EnrollmentV2].[dbo].[CPSC_Contract_Info]