Cade Bryant


Technical Article

Modified sp_who - more info & extra parameter

This procedure, sp_who3, is based on the system-supplied sp_who2, but is modified to return the actual text of the commands executed by each spid.  Very helpful for troubleshooting!  In addition, I have added a @hostname parameter to allow the user the option of viewing activity originating from only one computer, if desired.

You rated this post out of 5. Change rating

2004-05-06

637 reads

Technical Article

Parsing an IP address into its separate octets

IP addresses are represented as xxx.xxx.xxx.xxx, where xxx is an integer between 0 and 255.  Each three-digit integer is called an octet, and all IP addresses comprise four octets.Help-desk applications and administrative tools often store the IP addresses for a company's PCs in a database.  An IP address can be represented either as a single […]

2.5 (2)

You rated this post out of 5. Change rating

2004-02-25

1,833 reads

Technical Article

Execute VBScript commands or .vbs files via T-SQL.

sp_ExecVBScript allows you to execute either a .vbs file or an ad-hoc VBScript command within a T-SQL batch.  Note that the command (whether it be ad-hoc or contained in the .vbs file) cannot have any code that requires user input (such as Input Boxes or Message Boxes).

5 (2)

You rated this post out of 5. Change rating

2003-11-05

7,449 reads

Technical Article

Creating a Dynamic Crosstab Query

Crosstab queries (also called "pivot tables") in which you know beforehand the number of column values to aggregate by, can easily be performed in T-SQL using CASE statements wrapped in the SUM function.  Where things get tricky, however, is when you don't know how many aggregation values exist, and you are required to write a […]

5 (2)

You rated this post out of 5. Change rating

2003-09-26

3,494 reads

Technical Article

A faster way to count rows in a table

SQL Server includes the COUNT function for counting a table's rows - however, it can be slow.  Although querying the "rows" column from the sysindexes table is faster, it is not always accurate (e.g., if a bulk load process has recently taken place).  In addition, you would not be able to use this method in […]

1.33 (3)

You rated this post out of 5. Change rating

2003-09-11

394 reads

Technical Article

A more efficient ForEach routine

SQL 2000's sp_MSForEachDB and sp_MSForEachTable are useful procedures for performing operations against multiple objects; however, they aren't always extremely efficient, because internally they use cursors to do their work.These 2 sprocs, sp_ForEachDB and sp_ForEachTable, perform many of the same tasks as their Microsoft-shipped twins, but run faster because they dynamically build the SQL string without […]

5 (1)

You rated this post out of 5. Change rating

2003-08-19

2,247 reads

Blogs

Redgate Summit Comes to the Windy City

By

I love Chicago. I went to visit three times in 2023: a Redgate event,...

Non-Functional Requirements

By

I have found that non-functional requirements (NFRs) can be hard to define for a...

Techorama 2024 – Slides

By

You can find the slidedeck for my Techorama session “Microsoft Fabric for Dummies” on...

Read the latest Blogs

Forums

Change IN for EXSITS

By Edvard Korsbæk

I have had a hard time to understand how to use EXISTS. I Always...

Error while an ADF pipeline runs stored procedures against Azure SQL Server MI

By river1

Dears, We are using Azure Data factory pipes to run some stored procedures against...

Clear Trace - Asking for SQL Server 2008

By rameshbabu.chejarla

Hi, I have SQL Server 2019 installed and when go the Clear Trace database...

Visit the forum

Question of the Day

The "ORDER BY" clause behavior

Let’s consider the following script that can be executed without any error on both SQL Sever and PostgreSQL. We define the table t1 in which we insert three records:

create table t1 (id int primary key, city varchar(50));

insert into t1 values (1, 'Rome'), (2, 'New York'), (3, NULL);
If we execute the following query, how will the records be sorted in both environments?
select city

from t1

order by city;

See possible answers