Andrew Poulter


User Defined Function for Padding Numbers

This scalar udf takes three parameters @Number INT, @Length INT, @Position CHAR(1) and returns a VARCHAR(50) string which pads @Number with zeros to the specified @Length either to the right or to the left, according to @Position ('L' or 'R').E.g. SELECT dbo.udf_PadNumber(5, 6, 'L') returns '000005' whereas SELECT dbo.udf_PadNumber(5, 6, 'R') returns '500000'. The function […]

2006-03-13 (first published: )

128 reads

Last Day of Month

A script was recently published (Last_Date_Of_Month) that returns the last day of a given month/year combination. I have simplified and improved on that script by eliminating the need to use a WHILE loop. This new script exploits the flexibility of the DATEADD function which allows you to assign negative numbers (thus effectively subtracting a given […]

2004-09-30

144 reads

Blogs

Renaming Files by Padding Numbers with PowerShell

By

Some time ago I had downloaded all the SQL Saturday XML files. I’ve been...

When do Statistics get updated?

By

Statistics objects are important for allowing the SQL Server Optimizer to make good estimates...

Power BI: Making Date & Time Keys

By

Saving the Day from Delay Part 2 Creating DateKey and TimeKey columns can be...

Read the latest Blogs

Forums

Date format - being overridden?

By NicHopper

Hi all, Got a strange one here that I hope someone can help with....

Best way to understand Querying much better

By pietlinden

What's the best way to get better at T-SQL Querying? Something like Read/do the...

Intermittent "nesting level exceeded" error

By julian.fletcher

We're having a very peculiar problem with the "Maximum stored procedure, function, trigger, or...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers