Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3230932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:59:07+00:00 2026-05-17T16:59:07+00:00

i want to place negative value in bracket like -2000 to (2000) for that

  • 0

i want to place negative value in bracket like -2000 to (2000)

for that i made a which is converting -1361236.75886298 to (1.36124e+006)

the function that i made for this is :

ALTER function [dbo].[IsNegative](
@Number NVARCHAR (500)
)
Returns nvarchar (200)
as
begin 
Declare @Number2 FLOAT
set @Number2=Cast (@Number as float)
Declare @result nvarchar (200)
if ( @Number2  <=0.0)
begin
Set @result='('+Substring (@Number,2,len(@Number))+')'
end
else        
begin
Set @result = @Number 
end
return @result
end

i want accurate answere
thanx in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:59:08+00:00Added an answer on May 17, 2026 at 4:59 pm

    What is the proposed usage of this function?

    This type of formatting is probably best left to the presentation layer (assuming that there is a presentation layer)

    The following function might be suitable for formatting individual standalone values that are to be concatenated into a longer string. It would probably not be suitable for formatting multiple values as you would want these all to aligned at the decimal point. For this you could investigate the str function.

    CREATE FUNCTION [dbo].[IsNegative](
    @Number DECIMAL(38,16)
    )
    RETURNS VARCHAR (50)
    WITH RETURNS NULL ON NULL INPUT
    AS
    BEGIN 
    DECLARE @result VARCHAR (50)
    
    /*Trim trailing zeroes and decimal point*/
    SET @result = REPLACE(RTRIM(REPLACE(REPLACE(RTRIM(REPLACE(@Number,'0', ' ')),' ', '0'),'.', ' ')),' ', '.')
    
    IF @Number < 0
        SET @result = '(' + SUBSTRING(@result,2,LEN(@result)) + ')'
    
    RETURN @result
    END
    
    
    GO
    
    WITH T AS
    (
    SELECT -1361236.75886298 AS N UNION ALL
    SELECT -2000 UNION ALL
    SELECT 2000
    )
    
    SELECT 
         [dbo].[IsNegative](N)
    FROM T
    

    Returns

    (1361236.75886298)
    (2000)
    2000
    

    Is that what you need?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to place property place holders in the ehcache.xml file (like ${}) so
I want to place an image to the right of the view. For that
I have 5-10 independent projects that I want place under version control using Git.
I want to place the variable $all right in the middle of $code, which
I want to place a trigger on a table which writes all inserted /
I want to place image on the page which stays on the page bottom-right
I have a concept that I want to put in place. It is for
I want to place a Webpart on a page that holds a subfolder of
Is it reasonable (or secure) to validate CAPTCHA via ajax? I want place a
I want to place a table on my page. I have two tables in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.