SQL: How to include an incrementing column in your query without a cursor or loop

I had the need to do a recursive call that included depth and sort orders. I wanted to reformat the sort orders in a single query without using a cursor or loop. Turns out there is an easy way with SQL 2005 or higher. @Folders is a table var from my CTE with Depth and […]

I can’t drop a database user: The user owns one or more databases

This was frustrating me a bit, as I wish SQL Management Studio would just prompt me to remove myself as owner from those db’s and let me drop. Nope. It doesn’t. So, what to do? Well, I used management studio to select another one of my accounts. I get the awesome message of “The proposed […]

How to fix SqlError: FILESTREAM feature is disabled.

I was trying to restore a database and got the error “System.Data.SqlClient.SqlError: FILESTREAM feature is disabled. (Microsoft.SqlServer.Smo) from the Restore Wizard. This baffled me a bit as I know I went into the DB Server setting in Sql Manager and specifically set that value to Allow it. Well, after smacking the computer around a bit, […]

SQL Script to extract address information into individual fields

I had a need to write a script or a program that would extract an address that is stored in one field and break it out into its parts. Address, Address2, City, State and Postal Code(zip code). It’s a real bugger to do in a single SQL statement, I had one but it was really […]

EntityDataSource and Relationships, why oh why did you not bring along my relationship?

I spent about 3 hours cursing up a storm over some data binding I was doing using the EntityDataSource against my Entity Framework context. I was feeling lazy and using the declarative data sources to bind against my grid for some automatic operations.  So, should be easy right? Slap on the data source, bind to […]

Update a table from a Select query

I had to update a table with missing product id’s using the item master table to do the correlation. This led to having to formulate a lovely SQL query that would let me update the table based on matching criteria. In effect, I knew the SKU in both records should match, so I could correlate […]

How to delete those pesky duplicate SQL records…

So every once in a while I find that I have some duplicate records in my database as a result of testing or development or plain oversight. How to remedy the situation? Well, its as easy as this simple SQL. delete sourceTable from YOURTABLENAME sourceTable, YOURTABLENAME compareTable where sourceTable.fieldWithDuplicatesToMatch= compareTable.fieldWithDuplicatesToMatch and sourceTable.PrimaryKey > compareTable.PrimaryKey Basically, […]

.NET Illuminator v1 Alpha Released to the wild

So….I finally decided to release my alpha version to all you hooligans who want to see whats under the hood of fellow .NET’ers applications. You can use .NET Illuminator to see all the UI objects in another .NET application and even manipulate them. Yes, pretend like you are in Visual Studios Form Designer and just […]

Let’s all jump into the pool..The SQL Connection pool that is..

I was out swimming in the data pool and I started thinking to myself, how many people are sharing the same pool without me even knowing they are there? How did I even get into the pool? And why is the water so cold? Well, if you are using ADO.NET with SqlConnection , you are […]