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!

Signed INT 1

Status
Not open for further replies.

JontyMC

Programmer
Nov 26, 2001
1,276
GB
I have column which is type int. How do I return a signed int in query, ie:

When 0, 0
When -1, -1
When 1, +1
When 123, +123
etc...

Jon

"I don't regret this, but I both rue and lament it.
 
select case when daColumn > 0
then '+'+daColumn
else ''+daColumn
end as daFormattedColumn
from daTable

note: daFormattedColumn will be a string

r937.com | rudy.ca
 
The INT datatype is intrinsically signed. I think what you are trying to do is format the value that has been returned.

I think you can achieve what you want:
Code:
case 
when intColName > 0 then '+' + cast(intColName as varchar)
else cast(intcolName as varchar)
end


Bob Boffin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top