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: )

156 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

149 reads

Blogs

MVP No more, But It’s OK

By

Embracing Limitations: Finding Strength and Purpose in Hard Times For four years, I was...

A New Word: Fitching

By

fitching – v. intr. compulsively turning away from works of art you find frustratingly,...

Copilot in Microsoft Fabric

By

Microsoft Copilot is an app that uses AI to help you find information, create content,...

Read the latest Blogs

Forums

needing to insert 2 sets of numbers to a table to use as ranges for a query

By roy.tollison

the ranges (a lot) need to have a preset spacing between each set of...

log shipping switchover and switchback

By coolchaitu

I have log shipping in my environment. Could you please let me know steps...

TSQL Help, Possible a recursive CTE

By erics44

Hi I have 2 tables Table A JoiningID, MainID 1010619, 646703 991840, 238649 991840,...

Visit the forum

Question of the Day

What's Wrong with this Table?

What's wrong with this code and causes an error?

CREATE TABLE Customer
(
    CustomerID INT NULL,
    FirstName NVARCHAR(50) NOT NULL,
    LastName NVARCHAR(50) NULL,
    Email NVARCHAR(100) NOT NULL,
CONSTRAINT CustomerPK PRIMARY KEY (CustomerID, LastName)
);


See possible answers