Category Archives: TSQL

Getting metadata from query using sp_describe_first_result_set

One of the tasks that eats a lot of my ETL development time is documenting the views and procedures I write. I need to know where exactly the data is coming from. sp_describe_first_result_set provides a flag for outputting the source … Continue reading

Posted in Documentation, ETL, Testing, TSQL | Leave a comment

Using a temporary table to handle sp_describe_first_result_set

In a previous post (Easing the Testing Stored Procedures with Temporary Tables) I introduced the sp_describe_first_result_set stored procedure. This procedure works like sp_executesql, except that it returns the columns that a query returns rather than the results of the query. … Continue reading

Posted in Testing, TSQL | Leave a comment

Using view as source for application

Recently someone posed a puzzling question on the MSDN forums (How to reorder a column in a table which also has a foreign key). They needed to be able to add columns to a table in a specific order. If … Continue reading

Posted in ETL, Testing, TSQL | Leave a comment

Splitting strings in SQL Server

One of the query pains in SQL Server involves a simple split of a string. You want to pass into a stored procedure a comma delimited list of items and use that in your procedure. In order to get a … Continue reading

Posted in TSQL | Leave a comment

Easing the Testing Stored Procedures with Temporary Tables

I think that we would all agree that we should test our code before we release it.  Sometimes it very easy to do so. For example, testing a view is not difficult.  Say you had to make a small change … Continue reading

Posted in Testing, TSQL | Leave a comment

Displaying parameterized string in SQL Server

One of the things that I do frequently is to put together some message that involves a template filled in with variables. For example, I want my error message to fit a certain pattern. Or I want to put a … Continue reading

Posted in TSQL | Leave a comment