Category Archives: SQL Server

A Stored Proc to return a stored paged resultset for any table!

The stored procedure below may help you get started writing your own stored proc to return a paged/sorted result set for most any table in your database.  It only works if the table has a unique id and the datatype … Continue reading

Posted in SQL Server | Leave a comment

Simple SQL Backup

Do you need a free, easy to use backup utility to distribute with your SQL Server based application?  If so, you can get one at http://www.simplesql.net.  I wrote this little utility to help out all the small businesses that don’t … Continue reading

Posted in SQL Server | 1 Comment

When Execute() is better than sp_executesql()

I usually use sp_executesql inside my stored procedures when I need to run some dynamic SQL.  But I recently came across a scenario where this didn’t work.  The maximum size of the input to sp_executesql is 4KB (2GB on 64bit though … Continue reading

Posted in SQL Server | 1 Comment

Negative Process ID (spid -2) in SQL Server

I didn’t know negative spids existed until I found one blocking other processes on my SQL Server 2005 box.  The source of the negative spid (SQL Server Process ID), specifically a spid of -2, was the Microsoft Distributed Transaction Coordinator … Continue reading

Posted in SQL Server | 24 Comments

Better Sortable Paging Stored Procedure for SQL 2000 or SQL 2005

I had a little time since my previous post to take the more efficient paging stored procedure created by Greg Hamilton and add sorting to it.  I provide two versions here.  There first is based on their example tables.  The … Continue reading

Posted in SQL Server | Leave a comment

Sortable Paging Stored Procedure for SQL Server 2000 and SQL Server 2005

Scott Mitchell and Greg Hamilton posted an excellent example for a stored procedure to support paging on web sites in this article: http://www.4guysfromrolla.com/webtech/041206-1.shtml.   Here, I have taken their best example one step further and added support for sorting as well.  … Continue reading

Posted in SQL Server | 2 Comments