How to find lineage between SSAS (Tabular Model) and SQL database - sql-server

We have 20+ tabular cubes with 300+ dimensions and was hoping to find - if there is some automated way to find what is the source for this dimension
Yes manually, I can get into Tabular model > Table Properties and can find what view and table are used to populate dimension. However not practically possible to get for 300+ dimensions.
And yes, I know some 3rd party provider such as SQL Sentry has some tools which can find that lineage.
But just wondering, is there any SSAS DMVs or any other script which can give these details?
Much appreciated for all your help
Note: Environment is On-Prem Microsoft SQL 2016 suite (SQL DB, SSAS and SSIS)

For compatibility level 1200 or above Tabublar models the QueryDefinition column of the $SYSTEM.TMSCHEMA_PARTITIONS DMV will show the source SQL statement for either each partition, or the entire dimension/fact table if it isn't partitioned. In the event that a full table or view name is used (instead of a query) the full SELECT statement will be displayed with the object name. This can be queried from either SSMS by connecting to the SSAS server and opening a new MDX/DAX query window or another tool such as Dax Studio. This DMV is specific to whatever model you're connected to, as opposed to the whole SSAS instance. In the example below the Name column is the name of the dimension from the model. Since Name is a keyword it will need to be enclosed in brackets.
SELECT QueryDefinition FROM $SYSTEM.TMSCHEMA_PARTITIONS WHERE [Name] = 'DimensionName'

Related

How to get table names as seen in SQL database with SSAS DMV/MDX query

I'm trying to build a report off the cubes we've built in SSAS, and I've found this documentation for DMV and MDX queries, but I can't find what I want. It can return the dimension names as seen in SSAS, but I want the table name as seen in SQL Server, i.e. if we have a table called billingLocation in the database I want that instead of Billing Location which is how it's seen in SSAS. Is this possible?
As an aside, can you pull fact tables from the same query type? I only see information about pulling dimensions.
Maybe it's too late but you can use LEFT(Column_Name,X) to get some characters. Could be useful
There is not an existed DMV in SSAS to load the dsv name of a measure group or dimension which related Cube schema. I think you have to create a program and connect to SSAS server with AMO.NET to get these information by yourself.
But there is an IDE to get these info and allow you to export to excel, it is not free(30 days free trial): MDXHelper, www.mdx-helper.com.
Hope this help you. Thanks.

Column check SQL Server

I have a lot of views and tables connected in Microsoft SQL Server. I want to check all the useless columns I have in the native tables. Is there a way to perform an automatic check if a column in a table is used or not in other tables?
Create a database diagram in SQL Server Management Studio. From here you can analyze how the tables/columns are related or not. Info here
Do a business model analysis and see which values are used, which are deprecated and start from there.
If you do any changes on the database, these changes have to be projected in any code connecting to that database.
Do not remove columns in tables just by looking at a database diagram. You would destroy any object-relational mapper.

Combobox record source from SQL Server

Combobox can be done if SQL Server table is linked. I want to remove table link. What is the record source of combobox which will get list from SQL Server directly? I am using Access 2013 and SQL Server 2014 Express. Thanks.
You can create a select query as a callback query and use that as rowsource for the combobox.
The query will pull the records "directly" from SQL Server.
There not really a practical means to do this that will “help” performance. However, you can certainly build a pass-through query. That means the local Access query will contain RAW t-sql (sql server syntax). This can often increase performance.
Another tip if the query in question has more than one table, then building a SQL view, and then linking to that view works well. You will STILL have a local link that appears as a linked table, and you put JUST the view name in the combo box row source.
You can build in code a DAO (or ADO) recordset, and then assign that recordset directly to the data source of the combo box, but such additional coding does NOT yield any more performance then using a view or a pass-through query (and the view or the pass-through query does not take any code, is less work and results in the same performance anyway).
So at the end of the day simply use a linked table, or as noted a linked view.

Convert MS Access Reports to SQL Server Reporting

I have a bunch of old reports in MS Access that I want to just move over to SQL Server.
Is this possible to do? What steps need to be taken?
Identify a Report to convert
Open the Report in MS Access in Design mode
Get an old copy of the report or run the report out of MS Access (as the basis of making a SSRS report)
Open the Report Properties and find the Record Source the Report is using: qry_Intermediary_Summary
Goto the Queries tab and right click the Query and choose Design View:
Right click and choose SQL View
Copy the MS Access SQL into SQL Management Studio
Edit the MS Access SQL so it is SQL Server compliant:
Escaped column names that are reserved SQL Keywords (eg GROUP)
Replace double quotes with single quotes
Make sure Table/Views exist
Remove Dollar signs
Convert Trim(...) to LTrim(RTrim(...)))
etc
When a Query uses nested queries we need to convert them to Stored Procedures and load the data in Temporary tables. eg
This SQL uses 3 nested queries:
qryTopStocks
qryTopStocksBuys
qryTopStocksSells​
We cannot make the queries Functions that return Tables because Functions dont support ORDER BY
We cannot turn the queries into Views because Views do not accept parameters
So we have to convert the queries into Stored Procedures:
Then in our DataSets we execute the Stored Procs into Temporary tables that we can join:
Once you have the Query and it is returning the exact results as MS Access (view the old report to check), then we can create a new report.
I have used the MS Access to SSRS conversion tool. It managed to get the MS Access report designs but couldn't extract data. These SSRS2005 version reports are in directory AAA. Copy the Report you are converting from the AAA folder into the BBB project folder.
Import the old SSRS2005 report into BIDS/SSRS2016:
Select all the controls and copy them onto a new SSRS2016 report. Then delete the SSRS2005 report from the project. You only need it to copy the controls retaining the design, fonts and styles.
In BIDS map all the controls to their field in the DataSet.​
UPDATE: I just found this, its quite helpful: https://www.databasejournal.com/features/msaccess/article.php/3705151/Converting-Access-Queries-to-SQL-Server.htm
And this is a really good explanation of MS Access queries vs SQL Server queries for linked dBs
https://www.mssqltips.com/sqlservertip/1482/microsoft-access-pass-through-queries-to-sql-server/

Can I "join" across datasources in SSRS?

I've got two datasources, one Oracle and one Sql Server. Due to circumstances that predate me (as in it was like this when I found it) some columns in the Oracle database contain PKs from lookup tables in the Sql Server database.
I am attempting to create a Sql Server Reporting Services report that will combine data from both the Oracle and Sql Server database; where the data to be reported is partially from Oracle but some of the values needs to be looked up in Sql Server.
I've got the datasources. I've got the DataSets. I just can't figure out how to show both datasets in the same tabular report.
Is this possible? If so how so? I'd rather not resort to a db link in one or the other databases as I'd like to handle this on the reporting side.
I don't think you can join directly, but you might be able to add a subreport that would query the second datasource by using the foreign key from the first datasource as a parameter. See: How to: Add a Subreport and Parameters (Reporting Services).
You could also try using the Lookup and Lookupset functions within your tablix.
Lookup is a 1 to 1 join while Lookupset is 1 to many and may need you to have your data concatenated if you want a set of strings out.
For Lookup the following is from the MSDN site with some tweaks for my simple mind
Lookup(Field you are joining from, Field you are joining to, Field you want back, Dataset of the field you want back)
The tablix should be linked to the dataset of your source (joining from).
And just realised this is from 2010, not 2014...so a necro-post!
you could also embed a table inside another table and pass the primary key to the embeded table.
You could create a linked server that would contain data from both instances. From the SSRS point of view you would have one single datasource.
You can use heterogenous services or oracle transparent gateway to run the report off the oracle side. Oracle can query the data from the SQL side.

Resources