SSAS Tabular DMV to get source query for a table - ssas

Need to get the source query and connection details for measures used in Tabular Model. Have tried below to get measure names:
SELECT * from $system.TMSCHEMA_MEASURES
We get TableID and measure calculations from above query executed against Analysis Server in SSMS. How do we get the Source query for the table and connection details.
Note:
Below query gives Table Names but not the query and connection details:
select * from $System.TMSCHEMA_TABLES

You can do the following:
select * from $System.TMSCHEMA_TABLES
Note the ID from the table you are interested in. Then:
select * from $SYSTEM.TMSCHEMA_PARTITIONS where TableID=<ID>
will show you query definition(multiple definitions if you have partitions) for SSAS Tabular Model table. Note the DataSourceID, then run:
select * from $SYSTEM.TMSCHEMA_DATA_SOURCES
This will show you connection details.

Related

DMV request for "Description" of the table for Power BI dataset

What I am trying to achieve is to add tables and columns descriptions programmatically to a Power BI dataset.
For this reason, I use Server Analysis Services to get access to the metadata.
I run a simple request:
select *
from $System.TMSCHEMA_PARTITIONS
As a result, I get a table with columns names:
ID
TableID
Name
Description
....
Now I want to select where the "Description" is empty.
select *
from $System.TMSCHEMA_PARTITIONS
where Description IS NULL
But I can't, I always get a syntax error:
Query (3, 7) The syntax for 'Description' is incorrect.
SQL reads it as a command and I don't know how to avoid it.
I have tried adding quotes and double quotes to the name of the columns, I tried adding a table reference and all of these combined, but nothing helps.
It works for "TableID" for example.
This one works:
select *
from $System.TMSCHEMA_PARTITIONS
where len([Description]) = 0

Selecting entire tables based on wildcard name values SQL - Tableau

What I'm trying to do is to pull out a subset of tables from a Google Big Query Dataset based on the name of those tables and then add those tables to a Tableau datasource without having to join or union any of the tables.
I want to pull out all the tables beginning with System_1, from the below dataset
System_1_Start
System_1_Middle
System_1_End
System_2_Start
System_2_Middle
System_2_End
System_3_Start
System_3_Middle
System_3_End
I have been able to do a wildcard search using Information_Schema.Tables to get all the names of the tables that begin with System_1, but I cannot figure out a way to then get all of the tables with those names as the output of the query (SQL below)
SELECT table_name
AS matchingTables
FROM dataset.INFORMATION_SCHEMA.TABLES
WHERE table_name LIKE 'System_1%'
How do I go about extracting those tables and not just the names of those tables?
~~~~~~~~~~~EDIT~~~~~~~~~~~~~
This is the best approximation as to how I could have done this but I'm getting a dataset not found error which is strange
SELECT *
FROM dataset
WHERE (SELECT table_name FROM dataset.INFORMATION_SCHEMA.TABLES)
LIKE 'System_1%'
Error Recieved:
Not found: Dataset dataset:dataset was not found in location EU
If I understand correctly you want the list of the table names in your dataset that start with "System_1_". You can obtain that with the following:
SELECT CONCAT("System_1_", _TABLE_SUFFIX) AS table_name
FROM `dataset.System_1_*`

Query just runs, doesn't execute

my query just runs and doesnt execute, what is wrong. work on oracle sql developer, company server
CREATE TABLE voice2020 AS
SELECT
to_char(SDATE , 'YYYYMM') as month,
MSISDN,
SUM(CH_MONEY_SUBS_DED)/100 AS AIRTIME_VOICE,
SUM(CALLDURATION/60) AS MIN_USAGE,
sum(DUR_ONNET_OOB/60) as DUR_ONNET_OOB,
sum(DUR_ONNET_IB/60) as DUR_ONNET_IB,
sum(DUR_ONNET_FREE/60) as DUR_ONNET_FREE,
sum(DUR_OFFNET_OOB/60) as DUR_OFFNET_OOB,
sum(DUR_OFFNET_IB/60) as DUR_OFFNET_IB,
sum(DUR_OFFNET_FREE/60) as DUR_OFFNET_FREE,
SUM(case when sdate < to_date('20190301','YYYYMMDD')
then CH_MONEY_PAID_DED-nvl(CH_MONEY_SUBS_DED,0)-REV_VOICE_INT-REV_VOICE_ROAM_OUTGOING-REV_VOICE_ROAM_Incoming
else (CH_MONEY_OOB-REV_VOICE_INT-REV_VOICE_ROAM_OUTGOING-REV_VOICE_ROAM_Incoming) end)/100 AS VOICE_OOB_SPEND
FROM CCN.CCN_VOICE_MSISDN_MM#xdr1
where MSISDN IN ( SELECT MSISDN FROM saayma_a.BASE30112020) --change date
GROUP BY
MSISDN,
to_char(SDATE , 'YYYYMM')
;
This is a performance issue. Clearly the query driving your CREATE TABLE statement is taking too long to return a result set.
You are querying from a table in a remote database (CCN.CCN_VOICE_MSISDN_MM#xdr1) and then filtering against a local table (saayma_a.BASE30112020) . This means you are going to copy all of that remote table across the network, then discard the records which don't match the WHERE clause.
You know your data (or at least you should know it): does that sound efficient? If you're actually discarding most of the records you should try to filter CCN_VOICE_MSIDN_MM in the remote database.
If you need more advice you need to provide more information. Please read this post about asking Oracle tuning questions on this site, then edit your question to include some details.
You are executing CTAS (CREATE TABLE AS SELECT) and the purpose of this query is to create the table with data which is generated via this query.
If you want to just execute the query and see the data then remove first line of your query.
-- CREATE TABLE voice2020 AS
SELECT
.....
Also, the data of your actual query must be present in the voice2020 table if you have already executed it once.
Select * from voice2020;
Looks like you are trying to copying the data from one table to another table, Can you once create the table if it's not created and then try this statement.
insert into target_table select * from source_table;

Azure Data Factory Data Flow source query support for FOR JSON AUTO

I am trying to use below query as source for my data flow but I keep getting errors. Is the fuctionality not supported in data flow?
SELECT customer.customerid AS 'customerid',
customer.customer_fname AS 'fname',
customer.customer_lname AS 'lname',
customer.customer_phone AS 'Phone',
address.customer_addressid as 'addressid',
address.Address_type as 'addresstype',
address.street1 as 'street1'
FROM customer customer
INNER JOIN customer_address address
ON customer.customerid = address.customerid
order by customer.customerid
FOR JSON AUTO, ROOT('customer')
I get the following error:
Notifications
Column name needs to be specified in the query, set an alias if using a SQL function
ADF V2, Data Flows, Source
The error is cause by that Data Flow Query doesn't support order by statement, not the 'FOR JOSN AUTO'.
See the error bellow:
Please refence Data Flow Source transformation:
Query: If you select Query in the input field, enter a SQL query for your source. This setting overrides any table that you've chosen in the dataset. Order By clauses aren't supported here, but you can set a full SELECT FROM statement. You can also use user-defined table functions. select * from udfGetData() is a UDF in SQL that returns a table. This query will produce a source table that you can use in your data flow. Using queries is also a great way to reduce rows for testing or for lookups.
SQL Example: Select * from MyTable where customerId > 1000 and customerId < 2000
The query work well in Copy active but false in Data Flow. You need to change the query.

Unable to query table on oracle schema

I have the schema HR and USER A and ran the following query
**select count(*) from emp_table**
Upon running this query no data was returned but the table has data but if i run the query like this
**select count(*) from hr.emp_table**
then the data is returned.
Thanks
Just check from which database you connected..may be you are connected to wrong database table which doesnt has any data..
As you mentioned the below query clearly suggest that you have table emp_table in hr database which has data:
select count(*) from hr.emp_table
To verify which database you are connected use below query :
select name from v$database;
OR
SELECT username, machine, program
FROM v$session
WHERE type = 'USER';
As your first SQL did not throw any error,Your current schema (Not HR) has emp_table table having no data.
When you use HR.emp_table, it is refereeing your emp_table of HR schema.
So it is always good to prefix schema name with table name.