Andrew Poulter


Technical Article

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 […]

You rated this post out of 5. Change rating

2006-03-13 (first published: )

149 reads

Technical Article

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 […]

You rated this post out of 5. Change rating

2004-09-30

146 reads

Blogs

A New Word: Ghough

By

ghough – n. a hollow place in your psyche that can never be filled;...

T-SQL Tuesday: Encryption and Data Protection

By

I have the honour of hosting this month’s T-SQL Tuesday. In case there’s any...

Parameterize your Databricks notebooks with widgets

By

Widgets provide a way to parameterize notebooks in Databricks. If you need to call...

Read the latest Blogs

Forums

Need to output table data into multiple CSV files

By Mh-397891

Hello, I created the below script to output 999 rows from SQL Server table...

Changing Database page Verify on a Database in an AG

By John D

I have a database on SQL 2019 in an Availability Group (AG) and I...

Alwyason availability group can set primary role permanently?

By SQL Galaxy

Hi. Two node windows clusters Node1 and Node2 and configured alwayson availability group. Will...

Visit the forum

Ask SSC Logo Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers