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.

One Way To Insert Many Rows Very Fast From Your .NET Application

This is my attempt to explain something that I have wanted to figure out for a long time.  I have read many articles on this very subject but they always seem to fall short for various reasons - generally by including way more detail or complexity than is necessary to… Read more

17 comments, 24,442 reads

Posted in New York City .NET on 11 May 2012

One Way to Work Around the .NET Setup Project’s Picky Version Number Behavior

If you don’t change the version number of your .NET project output every time you create a setup package, you may have found that it’s difficult to have the Setup program reliably uninstall the existing version of your software before installing your update.

Here’s how to add a batch file… Read more

0 comments, 1,061 reads

Posted in New York City .NET on 10 May 2012

SmartPaster

I recently discovered this great little free Visual Studio Add-in that allows pasting text as preformatted strings in VB or C#.

Meaning it will turn this text:

This is line 1.

This is line 2.

To this when pasted:

“This is line 1.” & vbCrLf & _

“This is line… Read more

0 comments, 423 reads

Posted in New York City .NET on 2 February 2012

Case Sensitive searches in T-SQL

I just ran into an issue with one of my applications where a SQL statement had updated a status code field to a lower-case status code such as “active”.  We were expecting “Active” in the application and as a result our application began exhibiting odd behavior.  There are a host… Read more

0 comments, 1,623 reads

Posted in New York City .NET on 19 January 2012

Excel for the DBA, Part 1–The Basics

This will be a series of handy hints for people that know SQL and are frustrated by Excel.  I am going to be writing this for Excel 2007 (what I currently have at work) but the tips should work for most recent versions.  The SQL stuff should also work with… Read more

0 comments, 601 reads

Posted in New York City .NET on 6 December 2011

An Attempt to Make SSIS Package Deployment More Reasonable

Full disclosure: There might be a better way to do this.  I am not aware of it.

Problems:

  1. Maintaining multiple DB environments (Local, Shared Dev, Staging, Prod) means needing to maintain multiple SSIS environments.
  2. SSIS packages are tricky to configure using the existing toolset – it’s easy to accidentally use…

Read more

0 comments, 987 reads

Posted in New York City .NET on 3 November 2011

Save a step: Using Computed Columns in a Table Variable (or Temp Table)

One of the databases that I support reports all money values in both the local currency and US Dollars.  Very often we will do all of our calculations in a table variable using the local currency and then calculate USD equivalents at the very end.

With this methodology, adding a… Read more

1 comments, 3,969 reads

Posted in New York City .NET on 28 October 2011

Tobias Ternstrom’s Great Denali Preview

Tobias Ternstrom from Microsoft gave a great talk at Tech Ed regarding upcoming features of SQL Server Denali.  His presentation was engaging, funny, and informative!

You can check it out on the Channel 9 site here (72 minutes):

http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DBI318

I have to say that I am very excited about all… Read more

0 comments, 1,135 reads

Posted in New York City .NET on 30 June 2011

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, 900 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, 873 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,601 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, 2,395 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, 1,515 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, 1,119 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, 378 reads

Posted in New York City .NET on 29 December 2010

Newer posts