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

help converting data in a query 1

Status
Not open for further replies.
May 17, 2006
54
US
I am writing a query and I have a field (voucher, nvarchar(20)) whose data looks as follows:

00002_vir
00003_vir
00012_vir
200001_vir

Basically, I need to strip off the "_vir" and left pad to 8 places with zeros and I need some syntax help.

So the end result of the query would look like:

00000002
00000003
00000012
00200001

Any help would be appreciated. Thanks....
 
SELECT SELECT RIGHT('00000000' + REPLACE(voucher, '_vir', ''), 8)
 
Thanks RG, worked like a charm. Is there some way you can improve your 4 minute response time? LOL, just kidding. Thanks again
 
Old guys type slow. [wink]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top