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

convert a varchar to a number in a query

Status
Not open for further replies.

sjjustina

IS-IT--Management
Apr 23, 2007
30
US
Hopefully this is an easy one. I'm trying to get an average of a length field but the field is varchar(8).

This is my query:
SELECT AVG(CONVERT(varchar(8), pcslength, 0)) AS AvgLength
FROM tag_detail
GROUP BY tagnum

The convert doesn't seem to be working. Is there another way to do this?
 
I don't get out much, but thanks for the offer. I'm glad you got it working, and best of luck with your new job! Sounds like you have your work cut out for you :)

Ignorance of certain subjects is a great part of wisdom
 
George - That function is sweet! (I missed it because we cross posted) I never thought to use vbScript like that.

Methinks it is worth a star :-D

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top