database() (scope function)
Changes the reference of the query to a specific database within the cluster scope.
database('Sample').StormEvents
cluster('help').database('Sample').StormEvents
Note
- For more information, see cross-database and cross-cluster queries.
- For accessing remote cluster and remote database, see
cluster()scope function.
Syntax
database(stringConstant)
Arguments
- stringConstant: Name of the database that is referenced. Database identified can be either
DatabaseNameorPrettyName. The argument must be a constant value and can't come from a subquery evaluation.
Examples
Use database() to access table of other database
database('Samples').StormEvents | count
| Count |
|---|
| 59066 |
Use database() inside let statements
The same query as above can be rewritten to use inline function (let statement) that
receives a parameter dbName - which is passed into the database() function.
let foo = (dbName:string)
{
database(dbName).StormEvents | count
};
foo('help')
| Count |
|---|
| 59066 |
Use database() inside stored functions
The same query as above can be rewritten to be used in a function that
receives a parameter dbName - which is passed into the database() function.
.create function foo(dbName:string)
{
database(dbName).StormEvents | count
};
Note
Such functions can be used only locally and not in the cross-cluster query.
This capability isn't supported in Azure Monitor
Feedback
Submit and view feedback for