Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

The Tally Table

This editorial was originally published on Aug 13, 2015. With Steve on holiday after Christmas, this is being republished.

I saw a someone post a question recently about solving a T-SQL problem. One of the answers given used a tally table, which the original poster didn't understand. A few follow up links pointed them in the right direction, but it got me wondering.

How many of you know what a tally table is and how to create one? I bet a few of you don't, which might mean you've never had the need. Or it might be a hole in your skill set and you didn't realize that a tally table can be very useful in solving a number of problems. Anything from generating dates to splitting strings. There are plenty more ways to use one, and feel free to mention more in the comments that others might not have tried.

I'm not sure the tally table is a core T-SQL skill, but I think it's an important one you should learn as you grow your skills. After you've mastered the basics (Insert/update/delete, aggregates, outer joins) Adding in an understanding of window functions, the APPLY operator, and CTEs are also important to allow you to become better at solving the problems you run into with more efficient T-SQL.

Steve Jones - SSC Editor

Join the debate, and respond to today's editorial on the forums

 
 Featured Contents
SQLServerCentral Article

PowerShell Day By Day: The Pipeline

Frank Dolan from SQLServerCentral

In this article, I wanted to discuss the PowerShell (PoSh) pipeline, which was confusing to me at first and took some time to get used to working with. I had used one in Linux before, but the PoSh one is more powerful, but also slightly different. Hopefully I can demystify some of the concepts for […]

External Article

Controlling SQL Window Functions with Framing

Additional Articles from MSSQLTips.com

I’ve used SQL window functions for years, but I’ve never fully understood framing. To truly master window functions, you need at least a basic grasp of framing and how to apply it to your queries. Framing is especially helpful when working with aggregate functions. How can you overcome this hesitation to try framing?

Blog Post

From the SQL Server Central Blogs - A Note and a Message: T-SQL Tuesday #193

Steve Jones - SSC Editor from The Voice of the DBA

This month Mike Walsh hosts T-SQL Tuesday. It’s been quite some time since he hosted (back at #4), but he answered my call for hosts and I appreciate that....

Blog Post

From the SQL Server Central Blogs - Power BI, Excel, OneLake – Dreams Do Come True!

DataOnWheels from DataOnWheels

I can’t believe it’s finally here! A way to have Excel live in OneDrive and access it from Power BI nearly live! We can officially short cut files to...

T-SQL Fundamentals

Site Owners from SQLServerCentral

For anyone else who needs to write queries or develop T-SQL code for SQL Server, Azure SQL Database, or Azure SQL Managed Instance

 

 Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

UNISTR Escape

In SQL Server 2025, I run this command:
SELECT UNISTR('*3041*308A*304C\3068 and good night', '*') as "A Classic";
What is returned? (assume the database has an appropriate collation) A: B: C:

Think you know the answer? Click here, and find out if you are right.

 

 

 Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Celebrating Tomorrow

Which of these is more appropriate for tomorrow?

Answer: SELECT NCHAR(0x1F384)

Explanation: Merry Christmas, or (in SQL Server 2025):

SELECT UNISTR('Merry \+01F384')

 

Discuss this question and answer on the forums

 

 

 

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.


SQL Server 2019 - Administration
i noticed the sqlhealth extende event is on by default , so can i reduce - hi, i noticed the sqlhealth extended event is on by default , and it logs many thing, Q1) can i reduce few thing so that file size and recording that is wirting from buffer to file can be reduced, thus i will save some resources. q2) and can i add few events which are required […]
SQL Server 2019 - Development
data type gets lost in data flow - Hi, in a simple oledb source->derived column->oledb destination    data flow, 2 of my date columns that are converted to varchar, format 101,  in the source view, ultimately seem to end up as unicode in the oledb destination.   And that seems to bring down the pkg.  everywhere else they are dt_str length of 30 . […]
is there a no code way to limit an ssis extract from excel to the 1st 21 rows? - is there a no code way to limit an ssis extract from excel to the 1st 21 rows of the sheet?   for now anything past that is just noise in what im doing.
SQL Azure - Administration
New-AzSqlInstanceServerTrustCertificate - Failed and no clues - Using New-AzSqlInstanceServerTrustCertificate to import a certificate and get the message New-AzSqlInstanceServerTrustCertificate: Long running operation failed with status 'Failed'. Additional Info:'An unexpected error occured while processing the request. Tracking ID: 'd21c42cd-515c-40b4-b8b6-60b851c66a39' I've confirmed that the parameters are correct and most articles I've looked at suggest just waiting and trying again. Needless to say, that hasn't worked. […]
Editorials
The Challenge of AI - Comments posted to this topic are about the item The Challenge of AI, which is is not currently available on the site.
The AI Bubble and the Weak Foundation Beam - Comments posted to this topic are about the item The AI Bubble and the Weak Foundation Beam
Refactoring SQL Code - Comments posted to this topic are about the item Refactoring SQL Code, which is is not currently available on the site.
Article Discussions by Author
Stairway to Azure SQL Hyperscale Level 6: Backup and Restore Internals - Comments posted to this topic are about the item Stairway to Azure SQL Hyperscale Level 6: Backup and Restore Internals
Deprecated Feature Tracking - Comments posted to this topic are about the item Deprecated Feature Tracking
Think LSNs Are Unique? Think Again - Preventing Data Loss in CDC ETL - Comments posted to this topic are about the item Think LSNs Are Unique? Think Again - Preventing Data Loss in CDC ETL
A Big PK - Comments posted to this topic are about the item A Big PK
The Read Committed Snapshot Isolation behaviour - Comments posted to this topic are about the item The Read Committed Snapshot Isolation behaviour
Working with JSON/JSONB Data in PostgreSQL using Python - Comments posted to this topic are about the item Working with JSON/JSONB Data in PostgreSQL using Python
SQL Server 2022 - Administration
Deadlock graph anomaly - I've come across what appears to be a strange deadlock anomaly. As seen in the attached image/XML, a typical deadlock is shown (bottom), but then a completely isolated process graph is also shown (top). The top section has appeared in multiple deadlocks on different unrelated databases/app processes. It doesn't appear to be involved in the […]
Change Tracking – Troubleshooting - I have change tracking configured in several databases, in QA and production environments, and we have config in place to feed from these databases to data warehouse databases. It works well, but ... In a QA environment, we have been receiving the following sev-16 alert for a few days: Change tracking autocleanup is currently not […]
 

 

RSS FeedTwitter

This email has been sent to {email}. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -