Tag Archive for SQL Server 2000

Please, no TRIM()?

A couple weeks back I was asked “How come Microsoft has yet to put TRIM() in SQL?” I don’t really know why there isn’t a TRIM() function in SQL Server. There is an LTRIM for function removing leading spaces. And an RTRIM function for removing trailing spaces. But there isn’t a TRIM function. Let’s be…

Checking EXISTS – What’s Your Practice?

Michael Swart (Database Whisperer) posted a great write up and interview with Brad Schulz that is worth checking out.  Michael’s post links to a post from Brad on the use of EXIST and what is required for the SELECT portion of the statement.  Hope you are still with me. Definitely worth the read and +1 …

Scripting Object Level Permissions

A while ago while making changes to a client database, I needed to determine all of the object level permissions that were in the database I was working on.  The system stored procedure sp_helprotect turned out to be pretty useful in obtaining this information.  The procedure accepts four parameters: sp_helprotect [ [ @name = ]…

Incrementing Values

Occasionally, I run across procedures that mimic the functionality of the IDENTITY property.  There are always various reasons for these procedures to exist, some valid and some not quite so.  Recently while trying to tune one of these procedures that someone had added interesting locking hints to a creative rewrite to the procedure was suggested.…

This blog entry brought to you by the procedure "sp_MSForEachDB"

My undocumented stored procedure of the day is sp_MSForEachDB. This procedure allows SQL statments to loop through all database names on a server with a dynamic SQL string. The procedure accepts the variable @command1 for the dynamic SQL string, and the database name is passed into the string through the use of "?". Unlike using…