1
當數字少於4時,則補充0前的數字,如何在sqlserver中做? 我的SQL是補充0當數字少時4
SELECT
tt.Ddate as PzDate,
cast(ltrim(RTRIM(tt.VouchClassCode)) +'-'+cast (tt.VouchNo as varchar(100)) as varchar(100)) as PzZh,
t.Digest as Zy,
t.Ccode as Kmbm,
ttt.Cname as Kmname,
t.Jfje as Jfje,
t.Dfje as Dfje,
tt.Bill as Zhidan,
tt.Checker as Shenhe,
tt.Book as Jizhang,
tt.VouchSource as Pzlaiy
FROM [TOBROS_CWT].[dbo].[Cwzz_AccVouchSub] t
left join Cwzz_AccVouchMain tt
on t.VouchId = tt.VouchId
left join Cwzz_AccCode ttt
on t.Ccode = ttt.Ccode
order by t.VouchId ,tt.Ddate,tt.VouchNo
請看到的畫面,我想改變PzZh格式, 例如 「銀-1」 到 「銀-0001」 怎麼辦,謝謝。