Advertisement

03.13.2008 at 05:19AM PDT, ID: 23238151
[x]
Attachment Details

Padding a integer field

Asked by Trudye in SQL Server 2005

Tags: Microsoft, SQL Server, 2005, T-SQL

I have a INT field that needs to hold a four byte value which works ok as long as the first byte is not a zero. I tried using the statement below, however it is not working. If the output value should be 0760 (as in the example below) Im getting 760. Can anyone see what the problem is?

Right ('0000' + CAST(SUBSTRING(ACT, 11, 3)as varchar (3)), 3) + '0',

ACT varchar (20)
ACT value = 00000000000768000000

Output field = out_Act
out_Act int
Start Free Trial
[+][-]03.13.2008 at 05:22AM PDT, ID: 21115364

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.13.2008 at 05:23AM PDT, ID: 21115367

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: Microsoft, SQL Server, 2005, T-SQL
Sign Up Now!
Solution Provided By: chapmandew
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628