Run queries across companies

Modified on Wed, 7 May at 6:13 PM

Working with multiple SAP Business One companies?
Do you wish you could run a query in one company but pull data from another company?

Yes, it’s possible!

Let’s say you want to consolidate data or just compare info between companies — like invoices from your Mexico and US branches. You can query across companies by referencing the database name in your SQL.

? SQL Example:

SELECT T0."DocNum", T0."DocDate"   

FROM OtherDatabaseName.dbo.OINV T0

? HANA Example:

SELECT T0."DocNum", T0."DocDate"   

FROM "OtherDatabaseName"."OINV" T0


? But wait! You must grant permissions for this to work:

? Permissions Setup

SQL Server:

  1. In SQL Management Studio, run:

USE [OtherDatabaseName];

CREATE USER [YourUser] FOR LOGIN [YourLogin];

EXEC sp_addrolemember N'db_datareader', N'YourUser';

  1. Replace [YourUser] and [YourLogin] with the account used in SAP.


SAP HANA:

  1. Connect to the target tenant database.
  2. Grant access to the user from the main company:

GRANT SELECT ON SCHEMA "OtherDatabaseName" TO "YourUser";

Be sure your SAP user has access to use Cross-Database Queries.

 

That’s it! Now you can run consolidated reports, comparison dashboards, or pull real-time data from multiple databases into one query.

 

A screenshot of a computer

AI-generated content may be incorrect.

 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article