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

Daily Coping 8 Jul 2020

By

I’ve started to add a daily coping tip to the SQLServerCentral newsletter and to...

Don’t be afraid of No

By

How many times have you been afraid to hear “No”? We have all been...

Spark .NET - Spark ML TF-IDF

By

Spark ML in .NET for Apache Spark Spark is awesome, .NET is awesome, machine...

Read the latest Blogs

Forums

DBCC CHECKDB output

By stevec883

I ran a DBCC on a database and it found some anomalies. Just looking...

Why is sys.master_files showing the size of RBS files as 0?

By hurricaneDBA

Dear Everyone I hope you are all safe in these strange times. I am...

In where condition use column value which contains column name

By rohit.kumar.barik

Hi Team, Greetings! I have below table. let table name =Emp I need to...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers