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!

Negative at wrong end

Status
Not open for further replies.

djj55

Programmer
Feb 6, 2006
1,761
US
Hello, SQL 2008R2
Is there an easy way to convert 25.00- to -25.00?
I have a file I import that has the negative on the right side, I import as varchar the do an update
Code:
UPDATE #SummaryTemp 
SET Purchases = CASE WHEN RIGHT(Purchases, 1) = '-' THEN '-' ELSE '' END  
            + REPLACE(Purchases, '-', '')
Is there a function or trick to do this a little easier. Note there are actually seven columns that get updated.

Thanks

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Thanks

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Is it coming back in your query like that or in the report? If it's in the report there should be a way to change the display settings for the field/column. Otherwise it's probably looking at a local setting on the machine to determine how to handle the negative numbers.
 
No it comes from the client like that as a pipe delimited text file that needs imported. The above works but was looking for a short cut (not udf).

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top