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

help with SQL query

Status
Not open for further replies.

NickMalloy

Programmer
Apr 15, 2005
68
US
I am trying to combine two column into one with an added'/' in between the values.

qryHeightWeight2.[Weight (lbs)] + '/' + Convert (decimal(10,2), round([Weight (lbs)]/2.2, 2)) AS totalWgt,

I am receiving an error

Syntax error converting the varchar value '/' to a column of data type int.

How can I accomplish this?
 
Code:
ltrim(rtrim(str(qryHeightWeight2.[Weight (lbs)]))) + '/' + ltrim(rtrim(str(Convert (decimal(10,2), round([Weight (lbs)]/2.2, 2))))) AS totalWgt

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
select cast[Weight] as varchar(10)) + '/' + cast(Convert (decimal(10,2), round([Weight]/2.2, 2)) as varchar(10))
from qryHeightWeight2
 
checkai, any ideas why the second part would be cutting out the decimal. I need two digits after the decimal?
 
probably the str() function...using convert or cast may work better...

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 

Use convert (e.g.)

convert(varchar,qryHeightWeight2.[Weight (lbs)]) + '/' + (convert(varchar,Convert (decimal(10,2), round([Weight (lbs)]/2.2, 2))) AS totalWgt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top