Cade Bryant


Technical Article

View all settings for all databases on your server

My stored procedure, sp_dbsettings, allows you to view, in a cross-tabular format, all the common options and their values for all the databases on your server.  Optionally, you can pass a database name as an argument if you just want to view the settings for one database (i.e., EXEC sp_dbsettings 'Northwind').  Otherwise it shows info […]

You rated this post out of 5. Change rating

2002-10-09

635 reads

Technical Article

Find the Nth Occurrence of a Character in a String

T-SQL's CHARINDEX() function is a useful for parsing out characters within a string.  However, it only returns the first occurrence of a character.  Oftentimes one needs to locate the Nth instance of a character or a space, which can be a complicated task in standard T-SQL.  This function I wrote, imaginatively named CHARINDEX2(), allows one […]

4.64 (11)

You rated this post out of 5. Change rating

2002-09-27

31,317 reads

Technical Article

Stored procedure sp_for

The sp_for procedure provides simple single-statement loop processing for T-SQL statements, similar to the FOR command in the C language or the DOS command-line utility by the same name.It's syntax is similar to that of the DOS command.  It takes an argument to represent a variable, initialize the variable, set an increment, set an end […]

You rated this post out of 5. Change rating

2002-09-13

898 reads

Technical Article

FASTCOUNT() User-Defined Function (SQL 2000 only)

SQL Server's COUNT() function is a slow and expensive way to count a table's rows because it scans the entire table or index.  FASTCOUNT(), which I created, is much more efficient for this purpose - its only drawback being that it may return inaccurate results if a nonlogged (e.g., bulk) data modification operation was recently […]

You rated this post out of 5. Change rating

2002-09-10

840 reads

Technical Article

Using UDFs to avoid cursors

Let's say you have 2 tables: a Contacts table and a PhoneNumbers table (which stores all the phone numbers for each contact).  You are asked to write a query that returns each contact's name and a comma-delimited string of phone numbers for each contact, something like this:FirstName    LastName   PhoneNumbers---------    --------   --------------------------John      […]

You rated this post out of 5. Change rating

2002-07-22

998 reads

Technical Article

Preventing accidental overwrites with update SPs

Say you wanted to create an SP for updating records in a database.  How would you do this in such a way as to allow your users to edit only a subset of fields in the record, without overwriting the other fields, and without requiring verbose IF blocks and CASE statements in your code?Simple.  Use […]

You rated this post out of 5. Change rating

2002-04-16

198 reads

Blogs

How to Run Databases on Kubernetes: An 8-Step Guide

By

In this step-by-step tutorial, learn how to run MySQL, PostgreSQL, MongoDB, and other stateful...

Episode 11 of Simple Talks: Oracle

By

The 11th episode is now live, recorded a few weeks ago at the PASS...

A New Word: Mornden

By

mornden – n. the self-container pajama universe shared by two people on a long...

Read the latest Blogs

Forums

What is the best index strategy for a table that gets truncated?

By water490

Hi everyone My SSIS package does a bulk insert of csv files into a...

Blob Storage automated downloads

By Brandie Tarvin

Dipping my toes into the waters of Azure and of course before I get...

Announcing SQL Server 2025

By Press Release

Comments posted to this topic are about the item Announcing SQL Server 2025

Visit the forum

Question of the Day

Running Steve's Code

Can you run this code in any of your SQL Server 2019 databases without error?

CREATE OR ALTER PROCEDURE [dbo].[StevesAmazingProc]
AS
    
        SELECT Consumer_ID ,
               Trend_Category ,
               Bit_Trace
        FROM    NewWorldDB.dbo.MarketTrend;
    
GO

See possible answers