|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I need to insert zero in the field by using the select query.
my query is like as below...... SELECT AppID + '-' + cast(CASE WHEN len(Batchid)=6 then batchid WHEN len(batchid)=4 THEN '0' +batchid ELSE 4545 END as varchar(10)) FROM Xaction WHERE (BatchID = '6191') AND (AppID = 'GPWHS') but it is not putting the preceeding zeros. pl. suggest. it is urgent Thanks Regards |
|
#2
|
|||
|
|||
|
Try this code
SELECT
right('0000000000'+rtrim(cast(numfieldname as char(10))),10) as numfieldname2 FROM tablename |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Sql server query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|