Using a Recursive CTE to Build Paths

Here’s the scenario. You have a hierarchical data set like categories, folders, etc. and you need to output the entire path for each.

Let’s say we take the category example and we have a table that looks like:

CREATE TABLE [dbo].[Category](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](max) NOT NULL,
	[ParentCategoryId] [int] NULL,
    -- normal PK script removed to keep this short

To get the full path for each category, the SQL would look like:

WITH CTE_CategoriesWithPaths AS
        c.Name AS [Path] 
    FROM Category c 
    WHERE c.ParentCategoryId IS NULL 
        cte.[Path] + '/' + c.Name AS [Path] 
        Category c 
        INNER JOIN CTE_CategoriesWithPaths cte 
            ON c.ParentCategoryId = cte.Id
    WHERE c.ParentCategoryId IS NOT NULL 
from CTE_CategoriesWithPaths

SQL Saturday Baton Rouge 2015

SQL Saturday Baton Rouge 2015 has opened registration! Please visit the website and sign up if you’re interested.

If you’re interested in development at all this is a must attend event. The sessions span all areas of development. As the site says:

Folks with the following skillsets are drawn to SQL Saturday Baton Rouge because of the professional networking, free training, and giveaways:

SQL Server Administrators
Business Intelligence Developers
Data Analysts
ETL Developers
C#/VB.NET Developers
Mobile Developers
Windows Server Admins
SharePoint Architects
SharePoint Developers
Network Administrators
Quality Assurance Analysts
IT Managers
Project Managers

They also have a call for speakers going on and I’m still trying to decide if I’m going to submit a session.

ASP.NET Forms Disabled CSS for BootStrap

The following CSS is to handle Enabled set to true in any WebControl.

/* -- Bootstrap Additions - ASP.NET Disabled ----------------- */

.radio.aspNetDisabled label,
.checkbox.aspNetDisabled label
    cursor: not-allowed;

    pointer-events: none;
    cursor: not-allowed;
    filter: alpha(opacity=65);
    -webkit-box-shadow: none;
    box-shadow: none;
    opacity: .65;

    background-color: #fff;
    border-color: #ccc;

    background-color: #428bca;
    border-color: #357ebd;

    background-color: #5cb85c;
    border-color: #4cae4c;

    background-color: #5bc0de;
    border-color: #46b8da;

    background-color: #f0ad4e;
    border-color: #eea236;

    background-color: #d9534f;
    border-color: #d43f3a;

.dropdown-menu > .aspNetDisabled > a,
.dropdown-menu > .aspNetDisabled > a:hover,
.dropdown-menu > .aspNetDisabled > a:focus,
.dropdown-menu > li > a.aspNetDisabled,
.dropdown-menu > li > a.aspNetDisabled:hover,
.dropdown-menu > li > a.aspNetDisabled:focus
    color: #777;

.dropdown-menu > .aspNetDisabled > a:hover,
.dropdown-menu > .aspNetDisabled > a:focus,
.dropdown-menu > li > a.aspNetDisabled:hover,
.dropdown-menu > li > a.aspNetDisabled:focus
    text-decoration: none;
    cursor: not-allowed;
    background-color: transparent;
    background-image: none;
    filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);