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

  • Home
  • SEARCH
  • 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 9184015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:56:34+00:00 2026-06-17T18:56:34+00:00

Is there any query or function which can convert any no into words. Likes

  • 0

Is there any query or function which can convert any no into words. Likes 1001 into One thousand one etc. i am using sql server 2005.

  • 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-06-17T18:56:35+00:00Added an answer on June 17, 2026 at 6:56 pm

    hi try the Below proc…. it gives the output you need….

    Procedure :

    CREATE FUNCTION fnNumberToWords(@Number as BIGINT)
    
        RETURNS VARCHAR(1024)
    
    AS
    
    BEGIN
    
          DECLARE @Below20 TABLE (ID int identity(0,1), Word varchar(32))
    
          DECLARE @Below100 TABLE (ID int identity(2,1), Word varchar(32))
    
          INSERT @Below20 (Word) VALUES
    
                            ( 'Zero'), ('One'),( 'Two' ), ( 'Three'),
    
                            ( 'Four' ), ( 'Five' ), ( 'Six' ), ( 'Seven' ),
    
                            ( 'Eight'), ( 'Nine'), ( 'Ten'), ( 'Eleven' ),
    
                            ( 'Twelve' ), ( 'Thirteen' ), ( 'Fourteen'),
    
                            ( 'Fifteen' ), ('Sixteen' ), ( 'Seventeen'),
    
                            ('Eighteen' ), ( 'Nineteen' )
    
           INSERT @Below100 VALUES ('Twenty'), ('Thirty'),('Forty'), ('Fifty'),
    
                                   ('Sixty'), ('Seventy'), ('Eighty'), ('Ninety')
    
    DECLARE @English varchar(1024) =
    
    (
    
      SELECT Case
    
        WHEN @Number = 0 THEN  ''
    
        WHEN @Number BETWEEN 1 AND 19
    
          THEN (SELECT Word FROM @Below20 WHERE ID=@Number)
    
       WHEN @Number BETWEEN 20 AND 99  
    
         THEN  (SELECT Word FROM @Below100 WHERE ID=@Number/10)+ '-' +
    
               dbo.fnNumberToWords( @Number % 10)
    
       WHEN @Number BETWEEN 100 AND 999  
    
         THEN  (dbo.fnNumberToWords( @Number / 100))+' Hundred '+
    
             dbo.fnNumberToWords( @Number % 100)
    
       WHEN @Number BETWEEN 1000 AND 999999  
    
         THEN  (dbo.fnNumberToWords( @Number / 1000))+' Thousand '+
    
             dbo.fnNumberToWords( @Number % 1000) 
    
       WHEN @Number BETWEEN 1000000 AND 999999999  
    
         THEN  (dbo.fnNumberToWords( @Number / 1000000))+' Million '+
    
             dbo.fnNumberToWords( @Number % 1000000)
    
       WHEN @Number BETWEEN 1000000000 AND 999999999999  
    
         THEN  (dbo.fnNumberToWords( @Number / 1000000000))+' Billion '+
    
             dbo.fnNumberToWords( @Number % 1000000000)
    
       WHEN @Number BETWEEN 1000000000000 AND 999999999999999  
    
         THEN  (dbo.fnNumberToWords( @Number / 1000000000000))+' Trillion '+
    
             dbo.fnNumberToWords( @Number % 1000000000000)
    
      WHEN @Number BETWEEN 1000000000000000 AND 999999999999999999  
    
         THEN  (dbo.fnNumberToWords( @Number / 1000000000000000))+' Quadrillion '+
    
             dbo.fnNumberToWords( @Number % 1000000000000000)
    
      WHEN @Number BETWEEN 1000000000000000000 AND 999999999999999999999  
    
         THEN  (dbo.fnNumberToWords( @Number / 1000000000000000000))+' Quintillion '+
    
             dbo.fnNumberToWords( @Number % 1000000000000000000)
    
            ELSE ' INVALID INPUT' END
    
    )
    
    
    
    SELECT @English = RTRIM(@English)
    
    SELECT @English = RTRIM(LEFT(@English,len(@English)-1))
    
                     WHERE RIGHT(@English,1)='-'
    
    RETURN (@English)
    
    END
    
    GO
    

    Test Queries…..

    SELECT NumberInEnglish=dbo.fnNumberToWords ( 18)
    
    SELECT NumberInEnglish=dbo.fnNumberToWords ( 67)
    
    SELECT NumberInEnglish=dbo.fnNumberToWords ( 947)
    
    -- Nine Hundred Forty-Seven
    
    SELECT NumberInEnglish=dbo.fnNumberToWords ( 984261)
    
    -- Nine Hundred Eighty-Four Thousand Two Hundred Sixty-One
    
    SELECT NumberInEnglish=dbo.fnNumberToWords ( 777999888)
    
    /* Seven Hundred Seventy-Seven Million Nine Hundred Ninety-Nine Thousand
    
       Eight Hundred Eighty-Eight */
    
    SELECT NumberInEnglish=dbo.fnNumberToWords ( 222777999888)
    
    SELECT NumberInEnglish=dbo.fnNumberToWords ( 555222777999888)
    
    SELECT NumberInEnglish=dbo.fnNumberToWords ( 7446744073709551616)
    

    Source From : http://www.sqlusa.com/bestpractices2008/number-to-words/

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

Sidebar

Related Questions

Is there any function in C on linux by which we can query MX
I am calling one function using dynamic SQL query which accepts TVP. Is there
Is there any function or library which can be used to clean the user
Are there any APIs available in Java to query jobs? In other words, I
Is there any way to create a pivot and/or cross-tab query using for SQLite
In Lua, using the type function on any number always returns 'number'. Is there
Is there any reliable alternative to parse_str() function for parsing a query string? I
Is there any way to get the work item query results preview pane to
Is there any better way to make this query work? I'm looking for a
Is there any way to stop or terminate long running Oracle query in JDBC

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.