4

We are migrating database from Rackspace to Azure. Our databases were deployed on Virtual Machines in rackspace. In our queries we are using Linked server to other databases. Basically cross database query. problem is that after migrating databases, we are unable to use linked server queries as Sql Azure db does not supports Linked Servers.

Kindly help.

UPDATE:

  • Not all databases are in azure. Some databases are with their respective owners in remote locations. We need to query database that are running outside Azure.

  • There's no VM for Sql Server in Azure. We are using Database as a service in Azure.

See the image below for more details

enter image description here

1

While not ideal, an alternative approach here could be to setup your Azure database as a subscriber to replication publications created from your on-premise database(s). Replication will allow you to limit the articles within the publication, filter the types of records, etc. which hopefully means you can minimize the publications to only send the data necessary to serve the traditional four-part queries. If you still want to utilize cross-database queries, you can always create a second Azure DB which would act as the subscriber to these publications and then utilize cross-database queries from your current Azure DB which may allow you to minimize any rewrites of existing functionality.

0
1

You can use cross database queries as explained here. For example, to make reference to a remote table on a query you need to create a data source:

CREATE EXTERNAL DATA SOURCE MyExtSrc
WITH
(
 TYPE=SHARD_MAP_MANAGER,
 LOCATION='myserver.database.windows.net',
 DATABASE_NAME='ShardMapDatabase',
 CREDENTIAL= SMMUser,
 SHARD_MAP_NAME='ShardMap'
);

Define an external table using that data source.

CREATE EXTERNAL TABLE [dbo].[all_dm_exec_requests](
 [session_id] smallint NOT NULL,
 [request_id] int NOT NULL,
 [start_time] datetime NOT NULL, 
 [status] nvarchar(30) NOT NULL,
 [command] nvarchar(32) NOT NULL,
 [sql_handle] varbinary(64),
 [statement_start_offset] int,
 [statement_end_offset] int,
 [cpu_time] int NOT NULL
)
WITH
(
 DATA_SOURCE = MyExtSrc,
 SCHEMA_NAME = 'sys',
 OBJECT_NAME = 'dm_exec_requests',
 DISTRIBUTION=ROUND_ROBIN
);

Finally, use the external table on SELECT statements.

SELECT TOP 10 
 [request_id],
 [start_time]
 [status],
 [command]
FROM all_dm_exec_requests
ORDER BY [cpu_time] DESC
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.