Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 add number mask to field so 1 = 0001?

Author  Topic 

hueby
Posting Yak Master

127 Posts

Posted - 2006-05-24 : 18:54:25
Hi,

I have a table from a SQL DB that has numbers like 1 then 115. Well, in a crystal report it will show 115 before 1. Can I put a "mask" in a store procedure so it will add some zeros in front of the numbers to display 1 before 115???

Like 0001 and then 0115?

Tool_Requisition_Number is the field I want to mask.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-24 : 18:59:37
Can't you just make the data type of the field in your report integer so that the sorting is correct?

SELECT RIGHT('000' + CONVERT(varchar(3), @i), 4)

Tara Kizer
aka tduggan
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-05-24 : 19:00:07
If Tool_Requisition_Number is an integer, this will work.


right('0000'+convert(varchar(4),Tool_Requisition_Number),4)


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -