Cade Bryant

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.

2004-05-06

628 reads

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)

2004-02-25

697 reads

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 (1)

2003-09-26

2,715 reads

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)

2003-09-11

379 reads

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)

2003-08-19

2,197 reads

Blogs

Azure Cosmos DB: real-time data movement using Change Feed and Azure Functions

By

In this article, we will focus on creating a data pipeline to ETL (Extract,...

Quick 6 month check – how are those learning goals going…?

By

So in January I wrote a blog post on some goals I had this...

Read the latest Blogs

Forums

Select n records in table X from a field on table Y

By luisalfonso70

Hi, hope someone can help with this. I've the table gifts_to_give: Id_give      number_of_gifts          name ...

Select n records in table X from a field on table Y table

By luisalfonso70

Hi, hope someone can help with this. I've the table gifts_to_give: Id_give      number_of_gifts          name ...

Error: 17892 Severity: 20 State: 1

By ismahar

Hi, I've been struggling for 5 days to solved this issue. We have a...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers

Question of the Day

Intersection

See possible answers