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
 Import/Export (DTS) and Replication (2000)
 Padding a field with zero's

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-02 : 11:06:53
Akshay writes "How do i pad a field? I need to replace all blanks in the field with 0's. for Eg 4500 will be 00004500. If i can do this with DTS it will great, while exporting my database to a flat file."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-02 : 13:36:58

declare @akshay varchar(8)
set @akshay = '4500'
select
@akshay as orginal,
convert(varchar(8),replace(convert(char(8),space(8-len(@akshay)) + @akshay),' ','0')) as formatted

 
There's about a million ways to do this. This is only one.

<O>
Go to Top of Page
   

- Advertisement -