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!

format data = show + sign?

Status
Not open for further replies.

myvision69

Programmer
Feb 3, 2006
18
US
i need to add a + sign if the value is greater than 0 in sql?

how can i do that?
 
Not fully clear on what you need but I think you are asking for something like this"

if ((select column1 from table1 where recnum=5) > 0)
begin
insert table1
into column2
where recnum = 5
End



With Great Power Comes Great Responsibility!!! [afro]

Michael
 
+ signs don't show for positive numbers. In order to show a plus sign, you need to convert your number to a string representation. This little code snippet should show you how.

Code:
Declare @Number Integer

Set @Number = -10

Select Case When @Number > 0 then '+' Else '' End 
       + Convert(VarChar(10), @Number)

Copy/Paste this in to Query Analyzer. Run it. Change the number to something positive, run it again.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top