Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Leading & Trailing zeros

Status
Not open for further replies.

mssql

Programmer
Apr 2, 2001
1
US
I have a situation where I need to display leading & trailing zero's from a numeric field. For instance if user enters 0950, when I select the data back from sybase it gives me 9.5 . How do I get it to display the total value 0950?

Would appreciate any help.
 
Hiya,

The easiest way to do this is to use the convert function. You can then make your number into a string and format the output as you wish.

Tim
 
In little details:

just change your select query using the convert funtion (convert the numeric field into int ):

Eg

select product_id from products

.....becomes

select product_id convert (int, products.product_id) from products

The output result
for product_id will show the trailing zero. You can convert into varchar for showing both zeros

' where product_id asumed to be an numeric field


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top