Gopal
Gopal

Reputation: 11972

How to have leading zeroes

Using SQL Server 2000

Table1

ID

001
0569
897
....

ID Lenght should be 4, if the lenght is 3 then it should add '0' in front.

How to do this.

Need Query Help

Upvotes: 0

Views: 153

Answers (1)

flipchart
flipchart

Reputation: 6578

See this link for two methods. Summarized:

SELECT RIGHT('0000' + CAST(ID AS VARCHAR(4)), 4) FROM Table1

Upvotes: 3

Related Questions