Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

New York City .NET

The author of the NYCdotNet blog is a VB.NET and SQL server developer living and working in New York City. The author seeks to promote clean, readable, efficient code in both VB and SQL from design to development, deployment, and application maintenance.

The Recursive CTE

(Yet another boring org chart example – except this one has multiple roots)

One of my apps has a hierarchial org chart in its database.  We don’t use the hierarchyid data type for this table.  Instead, each row in the table just has a unique org ID and… Read more

4 comments, 563 reads

Posted in New York City .NET on 18 May 2011

How to determine the current SSIS runtime environment

If you want to test if you’re currently debugging an SSIS package via BIDS/Visual Studio, or running normally via DTExec, you can use the following utility functions inside a Script task.

    Public Function SSIS_IsBIDS() As Boolean

        Return (SSIS_Environment() = "DtsDebugHost")

    End Function

    Public Function SSIS_IsDTExec()… Read more

1 comments, 526 reads

Posted in New York City .NET on 28 April 2011

Renumbering Rows in a Table Variable (or Table/Temp Table)

I was recently working on a data cleanup problem where I had to do lots of comparisons of one row to the next row and I was trying to do my best to avoid using cursor for this.  I was using the old trick of having an IDENTITY() field and… Read more

4 comments, 1,050 reads

Posted in New York City .NET on 18 February 2011

Creating a deep hierarchy with FOR XML

I have two tables in an application that I support.  One is called [Report], and the other is [ReportParameter]. 

 

      --SAMPLE DATA

      DECLARE @Report TABLE (

            ReportID INT PRIMARY KEY,

            Title VARCHAR(30),

            TitleHelp VARCHAR(100),

            ReportName VARCHAR Read more

2 comments, 981 reads

Posted in New York City .NET on 27 January 2011

Using the MERGE statement

I love MERGE.  You know all those awful IF BEGIN END ELSE BEGIN END blocks you need to write for SQL Server?  A well-written MERGE statement can eliminate a lot of them!  Let's do a quick intro.
--Prepare test tables.
DECLARE @MyProducts TABLE (
      ProductID INT

Read more

1 comments, 905 reads

Posted in New York City .NET on 17 January 2011

Wiring up a common click event handler in an ASP.NET page

I was just refactoring a server-side control and ran into some horrible code.  Basicaly there was a big listbox that was supposed to hold people's names with letters A through Z to the left which were ASP.NET LinkButtons.  lnkBtnA, lnkBtnB, etc.  Each link button had its own click handler whose…

Read more

0 comments, 766 reads

Posted in New York City .NET on 30 December 2010

How to tell if a property exists by name

I recently was working on a library to manage reports in an application (probably a good candidate for an open source project) and needed to be able to grab the value of a property on an object by name without knowing if that property existed or not.  Of course .NET reflection comes…

Read more

0 comments, 245 reads

Posted in New York City .NET on 29 December 2010

Newer posts