THE SQL Server Blog Spot on the Web
Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | Join | Help
in Search

SQLBI - Marco Russo

SQLBI is a blog dedicated to building Business Intelligence solutions with SQL Server

  • Get SQL Server allocation info inside SSMS

    I just installed the Allocation Information add-in for SQL Server Management Studio.  It's very cool having this tool integrated into SSMS. It is a free add-in published on CodePlex. Take a look, it does worth the download in my opinion.


  • IQueryable under the cover

    In the Programming Microsoft LINQ book we dedicated two whole chapters (76 pages) about the writing of a IQueryable LINQ provider: one is about expression trees and the other covers the several ways to extend LINQ, including the writing of an IQueryable provider. I know that the subject is complex and probably is not necessary to every programmer. However, a good understanding of what happens under the cover of an IQueryable provider is good for everyone using any flavor of LINQ: when you debug your code, it might help you in finding issues faster.

    I wrote this introduction just to explain why you should read this post of Bart De Smet, which is undoubtedly shorter than the corresponding chapter of our book and gives you a very good step-by-step introduction of the inner workings of an IQueryable LINQ provider. Then, if you really like this kind of things, you have another good reason to read the book :-)


  • The use of FOR XML PATH for string concatenation

    I've just read this interesting article from Anith Sen that lists many different ways to concatenate several row values into a single column (i.e. one row for each category with a field containing a comma separated list of products for that category).

    I admit I never thought to use the FOR XML PATH solution to get this kind of result. Not only this is a very elegant way to write the query (you formally are not using other recursive approaches based on CTE), but it seems to be also the better solution from a performance point of view. I didn't compared it with the CLR based one, but the performance seems to be so good with the FOR XML PATH solution that I think I will use that by default unless performances are very very critical - I would consider the CLR based solution only if I already have a CLR assembly deployed, but I wouldn't deploy an assembly just for this feature.


  • Important LINQ Changes in .NET 3.5 SP1

    Dinesh Kulkarni wrote an important post about changes in LINQ introduced by .NET 3.5 SP1 that has been released yesterday.

    One of the interesting changes is in the Cast<T> operator and its behavior is better described in this post by Ed Maurer. I think that the side effects of this change should be limited, because the use of explicit type for the range variable in a query expression (i.e. from int n in numbers select... instead of from n in numbers select...) is not very common. In fact, I don't remember examples of its usage in our Programming LINQ book. Take care of this change if you used (or will use) this syntax.


  • Mark Russinovich at Virtualization Congress (London)

    A few months ago I talked about SQL Server Virtualization. For me, taking a look at virtualization improvements is very important, because I still think that not every database can be virtualized, but many of them probably yes! And the trend is that the number of databases that can be "virtualized" is growing for each new version of the virtualization environments. Hyper-V is an important milestone for Microsoft in that direction.

    That said, I know that a lot of people (like me) have to make a decision about virtualization today, but they also want to get an overview of emerging trends and products in this market. A good news for us is that an international independent congress will be held in London on 15-16 October, 2008: the Virtualization Congress 2008.

    Looking at the agenda, I discovered that Mark Russinovich will be the speaker from Microsoft and he also registered a promo video for the conference. Other speakers are from the most important players in this market. This conference is very different from the technical conference I'm used to attend from Microsoft (in fact, it is not from Microsoft!). However, the presence of people like Mark grants me that it shouldn't be a set of marketing sessions.

    Another good excuse to visit London (if you, like me, are not from UK) after SQLBits.


  • It's not a bug, it's by (bad?) design

    <rant mode="funny">

    Most of the time I submitted an issue to Microsoft Connect, I got a "it's by design" answer. I've been always irritated by this sentence because they don't admit in this way that they have a bug. Today, I understood I'm wrong. It's a bureaucracy issue.

    If you pretend that something is a bug, you are stating that a developer wrongly coded a program because it does not meet the requirements and the specifications. If the design is wrong, and the program is written "by design", then the program is wrong but you cannot say it has a bug.

    Now, what if the design is wrong? Simple: we don't have a way to submit a design issue. In the Microsoft Connect site you have only two forms: the bug form and the suggestion form. Please, add a third form: I need the design issue form. May be nobody thought this before. It could be that simple? May be... Now the question is: what is the right form to ask for the add of a new form? I hope somebody can help me with this.

    </rant>

    For those of you who are asking what has been the issue that exceeded the "enough is enough" limit, take a look at this one, which has received an answer more than one year (one year!) after its submission. Technically speaking, the behavior of CAST is right. However, it requires that you convert a VARCHAR into a FLOAT and then into a NUMERIC if the initial string contains a number in exponential form. I know that in this case the "by design" answer has solid foundation and don't justify my reaction :-) but you know... I was right several other times and this time the "by design" answer started my post minutes before I realized that design reasons were good... too late, my rant was too funny to be deleted :-)


  • Microsoft client and server strategies about BI

    The last news is the acquisition of DATAllegro by Microsoft. From a server point of view, Microsoft is doing well (even if not fast as I'd like). But is on the client side that I (and many other customers) are disappointed.

    I totally agree with the post of Chris Webb about XLCubed, where he also explains the issues of Microsoft client tools that are on the market today. I know, we have to wait until Office 14 and/or PerformancePoint 2.0 before having a more advanced BI tool. We only have to think what to say to customers that would like to make strategical investment today and don't want to wait other 2 or more years just to get a client tool that is able to leverage on features that (for example) Analysis Services offered since 2005.

    The reason for not investing too much on a third party tool is simple. Until three years ago, Panorama and ProClarity were the most important OLAP tools you could use with Analysis Services. Then, Microsoft acquisition of ProClarity stopped most of its development (because of the need to integrate it with PerformancePoint) and Panorama failed to update its client to leverage on new SSAS 2005 attribute-based paradigm. If only someone predicted the inability of Microsoft to deliver a full-featured client OLAP product, updated with fancy graphics, within 2006/2007, a very good move in 2004 would have been developing a ProClarity equivalent product made using .NET and WPF as development platform. Today, it would have been a killer-app, especially if you consider that Silverlight 2 allows you to deliver the fancy animated charts in a simple way. Today, I don't see any "wow" OLAP client on the market that I can plug to SSAS using all the SSAS features and power.

    As Chris said, binding the release cycle of OLAP tools to the release cycle of Office hasn't been a good move. The sessions announced for the Microsoft Business Intelligence Conference 2008 don't anticipate much for the near future. Yes, we have to wait for Office 14...


  • The adoption of LINQ

    Eric White has written an interesting post titled "Are developers using LINQ?" - there are interesting considerations about the adoption of functional programming too, but the most interesting part for me is the list of comment of the post. A lot of people described the adoption of LINQ into their team or company, and there is a spread variety of comments (good and bad).

    An interesting comment is about the future adoption of F# when it will be shipped, because of the complete adoption of functional programming (C# 3 is not a complete functional programming like F# is). I suggest you to take a look at this post and its comments, because it gives you an idea of what is going on out there.


  • SQLBits in UK

    I would like to attend to SQLBits this year, but my agenda is already overbooked. I hope you have the time to attend because there are a lot of interesting sessions, it's a good excuse to visit London (the conference is scheduled on September 13, 2008 - it's a Saturday) and there are very good speakers. The conference is free, but registration is required. A training day (with a reasonable fee) is also scheduled the day before. If you live in Europe, save the date!


  • MDX best practices analysis using MDX Studio

    Mosha released a new version of MDX Studio (0.4), which offers an "MDX Analysis" function that suggest best practices for a given MDX query.

    I tried the tool with some MDX query and it offers very good suggestion (when possible with link to further information about the issue) for both the MDX beginner and the MDX veteran. Sometime, the suggestion cannot be applied because you really want to make a particular "slow" calculation, but in general the approach is pretty good. A further step would the a "pluggable" architecture to extend best practices rules, just as FxCop does. However, chances are that not so many peopla have the time to implement additional rules, so it could be a useless effort and Mosha's time would be better spent on extending existing rules in the future.


  • CREATE GLOBAL CUBE statement does not support cascading M2M relationships?

    Thanks to a comment sent by a reader of my M2M paper, I just found a possible bug (or "not supported by design feature") of the CREATE LOCAL CUBE mdx statement. In short, it seems that a simple many-to-many dimension relationship is supported, but if you have a cube with multiple many-to-many dimension relationships chained together, this statement does not work. More details are described in the bug I opened on Connect site: https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=354521

    I know that CREATE LOCAL CUBE is not the best way to create local cubes. This paper explains why. However, this is the statement that Excel 2007 uses to create Offile cubes. So, this bug compromise the ability to put a cube offline with Excel 2007 if you have cascading many-to-many relationships chained together.


  • Sample chapters from Programming LINQ

    Two sample chapters of my Programming Microsoft LINQ book are finally available. Links to download pages in the chapters title.

    Chapter 6 - Tools for LINQ to SQL

    In this chapter, we took a look at the tools that are available to generate LINQ to SQL entities and DataContext classes. The .NET Framework SDK includes the command-line tool named SQLMetal. Visual Studio 2008 has a graphical editor known as the Object Relational Designer. Both allow the creation of a DBML file, the generation of source code in C# and Visual Basic, and the creation of an external XML mapping file. The Object Relational Designer also allows you to edit an existing DBML file, dynamically importing existing tables, views, stored procedures, and user-defined functions from an existing SQL Server database.

    Chapter 16 - LINQ and ASP.NET

    This chapter showed you how to leverage the new features and controls available in ASP.NET 3.5 to develop data-enabled Web applications, using LINQ to SQL and LINQ in general. Consider that what you have seen is really useful for rapidly defining Web site prototypes and simple Web solutions. On the other hand, in enterprise-level solutions you will probably need at least one intermediate layer between the ASP.NET presentation layer and the data persistence one, represented by LINQ to SQL. In real enterprise solutions, you usually also need a business layer that abstracts all business logic, security policies, and validation rules from any kind of specific persistence layer. And you will probably have a Model-View-Controller or Model-View-Presenter pattern governing the UI. In this more complex scenario, chances are that the LinqDataSource control will be tied to entities collections more often than to LINQ to SQL results.

    The following is the complete list of the chapters included in the book.

    Programming Microsoft LINQ

    • Part I LINQ FOUNDATIONS
      • 1 LINQ Introduction
      • 2 LINQ Syntax Fundamentals
      • 3 LINQ to Objects
    • Part II LINQ to Relational Data
      • 4 LINQ to SQL: Querying Data
      • 5 LINQ to SQL: Managing Data
      • 6 Tools for LINQ to SQL
      • 7 LINQ to DataSet
      • 8 LINQ to Entities
    • Part III LINQ and XML
      • 9 LINQ to XML: Managing the XML Infoset
      • 10 LINQ to XML: Querying Nodes
    • Part IV Advanced LINQ
      • 11 Inside Expression Trees
      • 12 Extending LINQ
      • 13 Parallel LINQ
      • 14 Other LINQ Implementations
    • Part V Applied LINQ
      • 15 LINQ in a Multitier Solution
      • 16 LINQ and ASP.NET
      • 17 LINQ and WPF/Silverlight
      • 18 LINQ and the Windows Communication Foundation
    • Appendixes
      • A ADO.NET Entity Framework
      • B C# 3.0: New Language Features
      • C Visual Basic 2008: New Language Features

  • To join or not to join: that is the question (in LINQ)

    A comment received by one reader of Programming LINQ suggested me to underline a concept that is not so intuitive using LINQ, especially if you come from years of SQL coding.

    The idea is very simple. Two entities in LINQ might be related in the model. Whenever this happen, usually it is better to leverage on this existing relationship and not to write the join syntax in an explicit way. If you are using LINQ to SQL, the generated SQL code might be more performant or at least correspondant to the one generated by writing an explicit join in your LINQ query. The less constraints in your query, the better.

    Let's look at an example on the Northwind database. Imagine you want to see a list of all categories with a flag set for the one which a particular product belongs to. This is a SQL query we could write:

    SELECT
        c
    .CategoryID, 
        c
    .CategoryName,
        CASE WHEN p.ProductID IS NULL 
            THEN 0
            ELSE 1
        END AS Selected
    FROM Categories c
    LEFT JOIN Products p
        ON p.CategoryID = c.CategoryID
        AND p.ProductID = 10
    ORDER BY CategoryName

    Ok, we can write the same query in many other ways, but there are several more complex situations where a LEFT JOIN is used to test the presence of an element in a related table. A correspondant LINQ query might be the following one:

    from c in dc.Categories
    orderby c.CategoryName
    join p in dc.Products.Where(p => p.ProductID == 10)
        on c.CategoryID equals p.CategoryID 
        into pj
    from x in pj.DefaultIfEmpty()
    select new {
        c.CategoryID,
        c.CategoryName,
        Selected = x != null
    };

    The LINQ query above will generate a SQL query containing a LEFT JOIN statement. However, a relationship exists between Categories and Customer, and you can leverage on this relationship in the point where you really need to traverse the relationship (in the projection statement). The following one is a better way to get the same result:

    from c in dc.Categories
    orderby c.CategoryName
    select new {
        c.CategoryID, 
        c.CategoryName,
        Selected = c.Products.Any( p => p.ProductID == 10 ) ? true : false
    };

    This new version has two advantages. First, it is shorter and express its intent more explicitly.  Second, it generates a SQL query with an EXISTS statement, similar to the following one.

    SELECT CategoryID, CategoryName,
        (CASE
            WHEN EXISTS(
                SELECT NULL AS [EMPTY]
                FROM Products AS p
                WHERE (p.ProductID = 10) AND (p.CategoryID = c.CategoryID)
                ) THEN 1
            ELSE 0
        END) AS Selected
    FROM Categories AS c
    ORDER BY CategoryName

    The execution plan used by SQL Server might be similar if not equal. However, using the implicit relationship between Categories and Products in the LINQ query is usually better, because it gives more freedom to the LINQ provider to generate a more efficient SQL code.


  • Great video resource to learn Data Mining

    I worked on Data Mining solutions years before Microsoft added it to Analysis Services. It is an interesting domain for everyone, but it becomes really hard to explain how it works when you scratch the surface. At the last TechEd Developers I watched a great presentation held by Rafal Lukawiecki - it was a level 400 session but he's able to explain the concepts very well, going deep at the right time. Now, there is a complete for part series recorded and available for free here: http://www.microsoft.com/emea/spotlight/sessionh.aspx?videoid=865

    It is a valuable resource and you cannot afford to stay away from Data Mining very long if you are into the BI deal.

     


  • What means writing a book

    I and Paolo Pialorsi have been interviewed at TechEd by Ken Rosen. We talked about our experience as book authors of Programming LINQ.

    If you are interested in writing a book, or if you simply want to see our faces and hear our italian accent, you can watch the video available in both low resolution and high resolution. Enjoy!


More Posts Next page »

This Blog

Syndication

Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement