Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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>