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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server String Manipulation 1

Status
Not open for further replies.

marcoman44

IS-IT--Management
Dec 22, 2003
62
US
I am trying to accomplish the following:

Field1
123456
12345678

I want the string to look like this through a query in SQL Server(Always 8 characters + *01)

00123456*01
12345678*01

In Access I am able to accomplish this through the Format Function, but this is not available in SQL Server.
Any help is greatly appreciated.

Thanks
 

One way

Code:
--field1 numeric

select right('00000000' + convert(varchar(8),field1),8) + '*01'

--field1 varchar/char

select right('00000000' + rtrim(field1),8) + '*01'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top