tim laqua dot com Thoughts and Code from Tim Laqua


Dynamic MDX queries in TSQL

Say you want to run the same MDX query for each row in a given rowset. I needed to do this for alerting purposes, where there were different alert thresholds for different attribute values in a given dimension attribute. After struggling with passing a variable to the query argument of the OPENROWSET command, I finally found the documentation that clearly stated that the query argument CAN'T be a variable. Or a concatination of a string and a variable. I still don't understand why... but the suggested workaround is to construct a giant TSQL string and run it using the EXEC command.

Ok - but how do we get the results of the query? Basically, the only way to do this is to create a temporary table in the current scope and do an INSERT INTO that temp table in your giant TSQL query. It all ends up looking something like this:


Starting a Business = Divorce?

So I was trying to find some sort of "start a business" packet with all the required forms and such - so I naturally searched Google for "minnesota start a business packet"

And what is the 3rd ranked hit? Starting a divorce. Nice.

Tagged as: No Comments