How to learn MDX [closed] - ssas

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am currently learning OLAP & MDX after many years of relational database development.
Any tips on getting started in MDX? What are the best books and resources to learn MDX?

A classic, albeit a bit dated, book is Fast Track to MDX. It's a great overview and a quick read, though it doesn't cover the new MDX features of SQL Server 2005.
The Spofford book MDX Solutions is more up date and a little deeper, but a bit harder to get through.
I also highly recommend the blogs of Mosha Pasumansky, Chris Webb, and Darren Gosbell.

Here is an MDX gentle introduction.

I found the Spoffard book not very helpful. MDX is such an oddity compared to other languages you'll learn, it's so hard to grasp from a dry book. I really would recommend a training course, otherwise you will flounder for ages. A course will really jump-start you, and it provides access to an expert when you have questions which don't seem to have online answers.
The worst trap to fall into, is to continually compare it with SQL! It uses some of the same keywords, but they mean something totally different, which makes the mental jump annoyingly harder.
I think the most efficient way to learn either OLAP or MDX would be to find someone who knows it, and get them to show you around, begin with some small changes, or some very simple queries.

You should also try and get hold of MDX Studio, a free MDX query tool written by Mosha Pasumansky (one of the original creators of MDX). It has similar MDX functionality to SQL Management Studio, but also allows you to parse and format queries, which can be very handy when trying to decipher them.

I prefer dragging and dropping fields around in MS Excel, and then using SQL Server profiler to capture trace against SSAS. This way, you get an awesome frontend for building queries, and then you can get the queries that Excel is using through the profiler.

If you create a Pivot Table that uses a cube (in Excel), you can see the query that is being sent using this (towards the bottom of the page)
http://www.codeplex.com/OlapPivotTableExtend
That might be a good way of getting a feel for the simpler stuff.
N.B. This is only in Excel2007, not sure about earlier versions

Book: MDX Step by Step
Video tutorials, e.g. MDX tutorial and Analysis Services introduction
There are more.

I would recommend
MDX with Microsoft SQL Server 2008 R2 Analysis Services Cookbook

We used the LearnItFirst.com training videos and found them to be a very thorough introduction to SSAS and MDX. There are around 40 hours of content plus exercises including around 6 hours of pure MDX Training.
The details for the SSAS Course can be found at:
Learn IT First SSAS Training

Besides the books and resources mentioned by others, the easiest way to kick-start your MDX learning is to get a copy of ProClarity. Unfortunately getting your hands on ProClarity is nowhere near as easy as it used to be. Microsoft bought the company in 2006, and it is now licensed through PerformancePoint, I believe. Oh yeah, and they quit development on the product.
Having said all that, if you are able to get a copy, you can build queries by dragging and dropping dimensions and measures onto your rows and columns. The results of the query are then displayed in either a grid, a chart, or both.
How does this help you learn MDX? ProClarity lets you see the MDX for each query. It isn't always the most elegant MDX, but it will help you quickly learn how to write lots of different queries.

Related

Looking for SQL Optimization Interview Questions

I'm on a project where I was asked to take a quick peek at some reporting SQL (in a SQL Server 2K5 environment) and was surprised at what I found: 4 to 5 levels of subquerys, distinct clauses, unions, and NoLock hints (which were needed because the SQL was running so long it was blocking standard processing) - all in the same set!.
Because I (foolishly :) mentioned that I thought the SQL was inefficient I've been labeled the "expert" and have been tasked with creating a test for a couple of interviewees to do that will assess their SQL optimizing abilities. I'm hoping someone can point me to some URLS, or maybe provide a list that I can use to help weed out the good from the bad.
Since you mentioned the SQL Server 2005 environment:
More SQL Server interview questions than you possibly could have imagined:
The classic set. Most interviewees will probably have studied these...maybe a good way to gauge who has prepared.
Another classic
Questions from one of the original Stack Overflow DBAs
Another link for best SQL questions and answers
I would give them a Query plan (via EXPLAIN, or whatever your flavor of SQL uses as a keyword) and see if they can decipher what it means, what the weak points are, and how to improve the query.
Look at MySQL's Explain Documentation for help using MySQL's explain and what it means.

Help finding old SQL tool that rewrote queries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
There was this old sql server tool called Lectoneth or something like that, you'd put sql queries in it, and it would rewrite it for you.
I think quest bought them out, but I can't find where to download a free copy of that software.
Really helps when you have no dba, and have lots of sql queries to rewrite.
Thanks
Craig
Doesn't ring a bell, and presumably you've seen, but nothing obvious on Quest's website
Perhaps a tool like Red Gate's SQL Prompt would help - the Pro edition does SQL reformatting.
Edit
Think i've found what you're looking for, mentioned here - LECCO SQL Expert. The link to the Lecco website does indeed direct to quest, but a 404.
LECCO SQL Expert is the only complete
SQL performance tuning and
optimization solution offering
problematic SQL detection and
automatic SQL rewrite. With its
built-in Artificial Intelligence (AI)
based Feedback Searching Engine, LECCO
SQL Expert reduces the effort required
to optimize SQL and makes even the
most junior programmer an expert.
Developers use LECCO SQL Expert to
optimize SQL during application
development. DBAs eliminate
problematic SQL before users
experience application performance
problems by using LECCO SQL Expert in
production systems.
Looks like it's no longer about - all mentions of I could find indicated it supported up to SQL 2000, and stale links - looks like it wasn't a free tool. As said in my comments, I think this kind of thing is a skill well worth possessing and would benefit in the long run to not relay on a tool to try and do it for you.
I wasn't aware of this tool before now, so I have picked up something from this question - got me intrigued!
Final Update:
To confirm, that product has indeed gone as Lecco was acquired some years ago now. Thanks to Brent Ozar for confirmation.
I think you're looking for a product that's been merged into Toad for SQL Server. The commercial version of Toad has a SQL Optimizer feature that tries lots of ways to rewrite your SQL statements, then tests them to find which ways are the fastest.
You can download Toad here:
http://www.toadsoft.com/
But be aware that that feature is a paid-version-only feature.
Well rather than spending your time looking for a magic bullet, why not spend some time learning performance tuning (you will need a book, this is too complex for the Internet generally). Plus it is my belief that if you want ot write decent new code, you need to understand performance in databases. There is no reason to be unable to write code that avvoids the most common problems.
First, rewrite every query to use ANSII syntax anytime you open it up to revise it for any other reason. Code review all SQl changes and do not pass the code review unless explicit joins were used.
Your first step in performance tuning to identify which queries and procs are causing the trouble. You can use tools that will tell you the worst performing queries in terms of overall time, but don't forget to tune the queries that are run frequnetly as well. Cutting seconds off a query that runs thousands of times a day can really speed things up. Also since you are in oprod already, likely your users are complaining about certain areas, those areas should be looked at first.
Things to look for that cause performance problems:
Cursors
Correlated subqueries
Views that call views
Lack of proper indexing
Functions (especially scalar function that make the query run row by row insted of through a set)
Where clauses that aren't sargeable
EAV tables
Returning more data than you need (If you have anything with select * and a join, immediately fix that.)
Reusing sps that act on one record to loop throuhg a large group of records
Badly designed autogenerated complex queries from ORMs
Incorrect data types resulting in the need to be continually be converting data in order to use it.
Since you have the old style syntax it is highly likely you have a lot of accidental cross joins
Use of distinct when it can be replaced with a derived table instead
Use of union when Union all would work
Bad table design that requires difficult construction of queries that can never perform well. If you find yourself frequently joining to the same table multiple times to get the data you need, then look at the design of the tables.
Also since you have used implicit joins you need to be aware that even in SQL Server 2000 the left and right implicit syntax does not work correctly. Sometimes this interprets as a cross join instead of a left join or right join. I would make it a priority to find and fix all of these queries immediately as they may currently be returning an incorrect result set. Bad data results are even worse that slow data returns.
Good luck.

Looking for exercises to learn SQL, using the Northwind database [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am trying to become more familiar with SQL by writing queries against the Northwind database.
I am looking for some exercises that would help me to learn SQL and features of SQL Server. It is important that the exercises have solutions, and in complicated cases, it would be great if there was an explanation for the query.
Thanks for the answers so far but I still have not found what I am looking for:
Is there any free resource, available online, without registration, that I can find a list of these exercises?
sql-ex is very userful site to learn sql.
Wikibooks have few exercises: SQL Exercises
I would pick up Inside Microsoft SQL Server 2005: T-SQL Querying. This book is great and has exercises + answers
I did an interview with the author a while back about this book, you can find that here: Interview With Itzik Ben-Gan Author Of Inside Microsoft SQL Server 2005: T-SQL Querying
A few things to focus on that will exercise a lot of areas of SQL that you should know if you're going to be writing a lot of it:
Joins - INNER and OUTER (difference between LEFT and RIGHT JOIN)
GROUP BY clause and working with aggregate functions such as SUM, MIN, MAX, etc..
WHERE - for filtering records returned in a query
Subqueries - Subqueries and Correlated subqueries
CASE, COALESCE, BETWEEN, CONVERT, CAST functions/statements
Find a good data set and try to run some meaningful queries on it. Make sure you start with a problem you want to solve (i.e. what is the average order amount for people who live in WA in the Northwind database?).
For a few simple problems/exercises:
http://caml2010.wordpress.com/2010/06/12/northwind-exercise/
The best way to learn in my opinion would be to work on a small hobby project.
For instance, lets say you are interested in sports, pick up your favorite sport and envision how you would model the sport statistics in the most elegant way in the form of a SQL database. You would start thinking on the lines of how to pull data out of the db, update the data , so on and so forth.
Whenever you encounter an issue, you can go look at the reference books (The T-SQL querying book mentioned above is a very good one) and figure out the best way of doing it.
Toy examples,exercises are good. But in my opinion, unless you really face a problem and solve it on your own, the fundamentals don't stick into your head.
Articles like this http://www.sommarskog.se/dynamic_sql.html are also extremely helpful, since they provide insight into how, why and why not.
Also check out this link http://www.sql-server-performance.com/tips/related_web_links_p1.aspx
If you have Reporting Services handy, or even Visual Studio, creating a few reports with aggregates, sums, counts etc will give you a little insight to how data can be used as information and really boost your SQL skills.
I work in a telephony company where this goes on all the time. I have this book sitting on my desk which I have found really handy.
Good luck! :)

Practical implementation of SSAS(Step by step)

I am a novice in SSAS with some theoretical knowledge in it.
I would like to do the very first and the simplest of all implementation in that.
I searched in Google but the one's I found are a bit high enough for me to grasp.
Could you please suggest me some good links/articles(Step by Step [ would be better if diagrams are given]) to start with.
I mean no inbuit AdventureWorks SSAS db. I like to say not the examples given in Microsoft Press book entitled SQL Server 2005 Analysis Services Step By Step (0735621993). Though it is good and basically helps to learn but I fell (after completing first 3 chapters) that there I need to install some already given DW's which I am not looking for
Everything should be from scratch so that I will learn properly though it may take a bit time.
Also it would be of great help to me and also for peoples like me if someone can tell direct the sequential steps to follow from start to end (like create dimensions, measures then cube etc. ) for creating a SSAS project.
You can find some step by step articles here.
http://technet.microsoft.com/en-us/library/ms170208.aspx
I recommend you Applied Microsoft Analysis Services 2005 and Practical Business Intelligence with SQL Server 2005
See this question for more info.

Library of Useful (Difficult) SQL scripts [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Does anyone know where I can find a library of common but difficult (out of the ordinary) SQL script examples. I am talking about those examples you cannot find in the documentation but do need very often to accomplish tasks such as finding duplicates etc.
It would be a big time saver to have something like that handy.
EDIT: Thanks everyone, I think this is turning into a great quick reference. The more descriptive the more effective it would be, so please if you see your way open - please edit and add some descriptions of what one could find. Many thanks to those that have already done so!
You may find this wiki on LessThanDot useful, for the most part, it is by Denis Gobo, Microsoft SQL MVP.
EDIT:
The wiki includes 100+ SQL Server Programming Hacks, the list is, I think, too long to include here, however, there is a comprehensive index.
Also available from the same site: SQL Server Admin Hacks.
Here are a few that I find very useful:
SQL Server Best Practices - Microsoft SQL Server White Papers and Best Practices
vyaskn - A mixture of articles From DBA to Developer
Backup, Integrity Check and Index
Optimization
SQLServerCentral Scripts - Scripts for most most DBA tasks and more
Script Repository: SQL Server 2005 - TechNet Script Center
Scripts and Tools for Performance Tuning and Troubleshooting SQL Server 2005
SQL Server Query Processing Team - Hardcore advice from the MS SQL optimisation team
Common Solutions for T-SQL Problems
Davide Mauri's Index Scripts
Some Administration stuff
Glenn Berry: Five Very Useful Index Selection Queries for SQL Server 2005
Find "Missing" Indexes for the entire instance of SQL Server
Find "Missing" Indexes for a single table
Examine the current index structure for a single table
Look at index usage for a single table
Look for possible bad indexes inside the entire current database
Drill into your workload (Bonus)
SQL Server Central: Seven Monitoring Scripts
Failed jobs report
Free space by drive
Disabled jobs
Running jobs
Server role members
Last backup date
SQL Log
And last, but not least this resource: SQL Server Programming Hacks - 100+ List
Joe Celko's SQL Puzzles and Answers
The Art of SQL (slight Oracle bias)
Sql Cookbook has a variety of interesting example, though some will undoubtedly be unsupported by your RDBMS of choice. O'Reilly also has a T-SQL Cookbook, but I've never personally read it.
directly from MS Script Repository: SQL Server 2005:
http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/default.mspx?mfr=true
Nigel's very usefull stuff:
http://www.nigelrivett.net/#TransactSQL
Forgive me for the self-advertising, but I have posted a few on my blog (http://progblog.wordpress.com) because I'm rubbish at SQL and it's a good place to store things I know I'll need in the future :-) If anyone has anything more substantial then please post, I'm as keen as anyone to get hold of something like this!
I would guess that a copy of the "SQL Cookbook" would help too.
I've had some use of these SQL "hacks" for Oracle a couple of times.
Concatenate as grouping function
In query data generation for joining purposes
Here is another link for SQL Server: best practices - dozens of script examples
http://www.sqlusa.com/bestpractices2005/
Check Out SQLCAT.com (MS SQL BEST PRACTICES TEAM)
Riffing off the Celko answer: SQL For Smarties. This has great in depth chapters that will augment the SQL Puzzles book. Also there is another Celko book I just learned of named
Joe Celko's Trees and Hierarchies in SQL for Smarties.