Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mask a string

Status
Not open for further replies.

PavanKumarU

Programmer
Jan 31, 2003
56
US
hi,
Got a quick questions. I dunno if i am misisng a function here.
I want a string which (if it is) is 5 chars in length to appear in 7 chars length.
for example.
If i am getting a string from database like 'Hello' i want it to be padded with two zeros like 00hello.
Can i do this is sql?
Any help is much appreciated.
Thanks
Pavan
 
select '00'+ ColumnNameContainingString from Table

will work if ColumnNameContainingString has a character data type. If it's something else:

select '00'+ cast(ColumnNameContainingString as varchar) from table
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top