How to use 3rd dimension in MDX query (ON PAGES syntax) - sql-server

I have a problems with 3rd dimension in MDX Query (on MS SQL Server 2005). I can use 3rd dimension in Visual Basic (I have a cube there, using browser I can make 3 dim. queries -- owing to ON PAGES). I snooped it via MS SQL Profiler (it records databases queries). But when I tried to put the query into MS SQL SERVER, only thing what I've received was:
Executing the query ...
Obtained object of type: Microsoft.AnalysisServices.AdomdClient.CellSet
Formatting.
Results cannot be displayed for cellsets with more than two axes.
Execution complete
I tried a few different ways to implement query, but this^ answer, was an only answer from a server.
The question is: What I need to do to use third dim in my OLAP?

When you query Analysis Services with SQL Server Management Studio (SSMS) you get an ADOMD.NET Cellset object. This object represents your query results in a multidimensional fashion, laying out the information in several axes: Axis 0 for columns, axis 1 for rows, axis 2 for pages, etc.
Although your query may be correct with three axes, SSMS can only render bidimensional restults, hence the error message you get. You need to build an application using ADOMD.NET to consume the cellset, or use a third party tool.

You say you "put the query into MS SQL SERVER" - what exactly do you mean? Did you try the cube browser that comes with Analysis Services? It's pretty rubbish.
I think the problem is as simple as the error message you got - "Results cannot be displayed". In other words, the viewing software can show tables (i.e. 2D info) but doesnt have a way to display 3D info (whether it be in multiple tables, or whatever).
You need to find software that can present cube data more elaborately.

Related

SSRS - OutOfMemory exception for Matrix report

I'm trying to design a Matrix report through SSRS to aggregate a column for a range of dynamic values in another column (i.e. a pivot). This data consists of just over 13 million rows, so it's a large dataset.
When doing a PIVOT on this data via T-SQL, it's able to aggregate all of these rows in about ~1min, however when getting SSRS to do the pivoting for me through a Matrix report, I'm getting an OutOfMemory exception when trying to preview the report on my PC.
The query returning the dataset itself isn't complicated, it's as simple as:
SELECT
ID
,Test_Ref
,Data_issue_indicator
FROM MyTable
Where we're trying to do the sum of Data_issue_indicator (which can be either a 1 or 0) for values in Test_Ref, in which there is a dynamic range of values to aggregate against; in other words we cannot use a standard Tablix report because the amount of columns can increase at any time should a new Test_Ref value be introduced into the dataset.
I'm using Visual Studio Enterprise 2019, and my PC is a Windows 10, i7-8850H, with 16GB memory.
Is there a suggestion on getting around this issue?
When using SSRS, its recommended to grab more data once in case of using the dataset multiple times. but when you have a larger dataset it needs to be a trade off between what you want to achieve against do you need all the data.
So in this situation i would suggest to use a procedure to restrict the amount of data that you are grabbing to the report.
I have gone through this sort of scenario, and i had to do the same, because its not the query that is timing out but the huge amount of data that is loaded to the report which fails the report.
If you have SQL server profiler , you would see the SQL executed and completed, but the report times out rendering.
Two ideas, assuming that you plan to deploy the report to a server that will have the memory to handle this, and that you'd prefer to do this processing on the report server rather than the SQL server for some reason:
Don't test the functionality on your PC in Visual Studio. Design the report, deploy it to your Report Server, and test it there to see if it works.
When testing on your PC, force it somehow to use a much smaller dataset: one just large enough to verify that the pivoting Matrix works, but small enough that your PC's memory can handle it.
Or better yet, do option 2, and then option 1.

Linked dimension performance issue

I am working with 2 star schema data warehouses, each data warehouse contains a fact table and the dimensions tables are located in separate databases (one database used by both data warehouses).
I created a multidimensional analysis project for each data warehouse:
In the first project, I defined the dimensions and deployed the Analysis database and I am able to browse the cube with no problems from Management Studio.
In the Second project, I defined Linked dimensions and used the deployed dimensions from the first analysis database.
When trying to browse the second cube everything is working fine, but when I tried to browse the dimension or to add a filter when browsing the cube the management studio is not responding. After many hours it returns the following error message:
Error occurred retrieving child nodes: The Messages element at line, (namespace urn:schemas-microsoft-com: xml-analysis: exception) cannot appear under Envelope/Body/ExecuteResponse/return/SubCube)
When searching for this issue, i found some article mentioning that using Linked dimensions are not recommended when analysis databases are located on different servers. But in my case the data warehouses and the analysis databases are on the same server.
Also i tried to run the same filter logic using MDX query using FILTER() with no luck. The MDX query syntax is similar to:
SELECT ([Dimension2].[---].[---], [MeasureGroup].[Measure]) ON COLUMNS,
FILTER([Dimension1].[---].[---],[Dimension1].[---].[---].CurrentMember.Name = "FilterValue") ON ROWS
FROM [AnalysisCube]
Note that: The dimensions contains more than 4 GB and CompatibilityLevel is set to 1100.
Any suggestions?
Based on the following Microsoft reference:
Exam Ref 70-767 Implementing a SQL Data Warehouse
SSAS allows you to add a linked dimension to that other multidimensional database so that you only have one dimension to build and maintain. However, the use of linked dimensions is not considered to be best practice in SSAS development because it can produce performance problems.
Another way to think about building once and reusing your development work is to save the .dim files in source control. You can then require new multidimensional database projects to add .dim files from source control rather than build a new dimension directly. That way, you can maintain the design in a central location and benefit from reusability without introducing potential performance issues.
From the information above, it looks like using Linked dimensions is not recommended from performance perspective.

SSRS - Spatial Data/Map report issue

I'm having trouble implementing what I feel should be a fairly basic report in SSRS (SQL Server 2014 and VS2013 Shell). I work for a company based in the UK and I want to show various data using the Maps functionality. To start with I simply want to take customer sales data and plot it over a basic UK map. To that end I have constructed a query which uses the customer postcode to obtain latitude and longitude values. I have then used STPointFromText to convert these to the Geography data type as follows:
geography::STPointFromText('POINT(' + CAST(longitude AS VARCHAR(20)) + ' ' +
CAST(latitude AS VARCHAR(20)) + ')', 4326) AS Geog
This dataset contains the sales figures, so the analytical and spatial data is all in one place (assuming I've understood this part correctly!).
When I query this data in SSMS and view the results under the Spatial tab, it looks quite promising, i.e. quite clearly plots the shape of the UK:
spatialoutput SSMS
However, when I try to represent this in SSRS, it falls apart. Using the SQL Server spatial query option as my data source, and using the query I constructed and ran in SSMS previously, I keep getting a popup window which reads:
'Unable to determine the spatial data type in the specified dataset field: Geog'
From here nothing works. I don't see any maps or any points like I did in SSRS. I've been searching for hours and not really found a solution, although I did find this on MSDN:
https://msdn.microsoft.com/en-us/library/hh272532.aspx
'You cannot use the dataset designer in Visual Studio for queries that return SQL Server spatial types. The dataset designer does not support user-defined types (UDTs), to which category the SQL Server spatial types (SqlGeometry and SqlGeography) belong.'
Various articles I have read showed people simply building a query like mine and then adding it as a dataset, after which it detected the spatial column and type straight away. Many did appear to be SQL Server 2008 R2 though. The article above implies a load of messing around with files in the GAC and the creation of a Windows Form Application, which presumably requires VS Pro and additional fiddling.
If anyone could point out where I'm going wrong it would be much appreciated!
Thanks in advance.

Exact matching w/ SSIS Fuzzy matching

I'm using the Fuzzy Matching SSIS component and want to do a fuzzy match on new names (from input columns Name1) against known names (Alias from Lookup Columns). Doing this alone works great (and is fast), but when I want to restrict the matching to only those records that have the same Country code as shown below, BTW both columns are char(3) is ISO codes, SSIS performance is so slow that it never completes.
I've attempted every variation of indexing available on the [Reference Table] tab and I believe I'm using the combination of Relationships correctly per https://msdn.microsoft.com/en-us/library/ms186488.aspx
Anyone run into a similar issue and figure out a workable solution?
Adding answer to question asked in comments here (better formatting);
SQL Server version : 2014 Ent
SSIS Version : not sure, but created w/ SQL Server data tool for VS 2013
Data Volume Source : 65K
Data Volume Data to Match : 105K (but SSIS pipeline gets stuck around 10k)
SQL Server indicates it's waiting for SSIS to pull more data in
Looking at task manager DTSdebug is using ~15% CPU and will do so indefinitely
The really odd thing is if I remove the country matching (which is set to exact) and use a larger source set (172K vs 65K) SSIS runs wonderfully.

MS Access 2007 queries does't run on SQL Server 2008

I am developing an application in C# VS 2010 past 4 months. I used MS Access 2007 to store my nearly 20 tables successfully.
Today I realized that my data base cannot be handled consistently by MS Access 2007. Hence I decided to go for SQL Server 2008 R2 Express with Upsizing wizard and it worked really great!
However, when I tried to run various options of my already well developed application, It kept throwing error each time when a query is fired to SQL Server.
I understood that Many of the stuffs of SQL supported by MS Access are not supported by MS SQL Server
For example: query with date, for representing date format when we use '#', SQL Server 2008 won' t recognize it.
Also, for Bool value, MS Access stores it as True and False where as SQL Server uses 0.
These all queries worked perfect with Access 07
I am sure that there must be some method so that SQL Server can understand MS access queries.
Or will I have to edit my whole application?? It will be as good as digging a mine for earning gold..
I have changed all data access objects such as reader, adapter, command, connection to SQL data objects using System.Data.SqlClient.
So, It is not the problem.
Please help me asap.
Thank you.
You cannot force SQL Server to run the MS Access queries. These queries will need to be rewritten to use T-SQL instead of the query language that MS Access uses.
I feel your pain, I just had to rewrite a large MS Access application (over 1k queries) that needed to be recreated to be used in SQL Server.
There will be some queries that might be able to be ported over directly but as you noticed queries with date, and even some of the aggregate functions (First(), etc) are not used in SQL Server and those queries will need to be changed.
Here is a link with some info on converting Access to SQL
Converting Access Queries to SQL Server
You are right that, most of the time, you cannot just take the SQL of a query from Access and run it within SQL Server. It may work for very simple queries, but usually you need to tweak them.
There are a few steps I would take:
Extract your queries (which I presume are in your code), and re-create them in your Access database. Make sure they work there as normal Access queries.
(you can for instance simply add some code to your app to print all queries to files so you don't have to mess with parameters, then just copy/paste them in your Access DB).
The point is simply to have working queries within Access.
Use SSMA from Microsoft for helping you to move your queries to SQL Server. It does a good job of translating them into T-SQL.
You may still have to convert some troublesome queries by hand, but it shouldn't be that many and usually the conversion is not difficult.
Once converted to T-SQL, just re-inject these working queries into your code, or keep the complex queries in SQL Server as views (which it usually be faster as SQL Server will have already created its execution plan, rather than your application sending raw SQL that the server needs to analyse).
As you pointed out, there could be some issues if your fields use some features that don't cross-over to SQL Server properly.
Look at your tables in Access and do some cleanup before attempting to convert:
For booleans fields:
Make sure you set their default values to 0 or 1 (they should not be empty).
Required fields must be non-null:
Make sure that any fields that you have set as 'Required' does not contain any NULL values in its data.
Unique indexes cannot ignore Null:
Check that your indexes are not set to be both 'Unique' and 'Ignore null'.
All tables must have clean primary keys:
Make sure all your tables have a unique primary key that doesn't have Null values in their data.

Resources