how to convert a number to string in SQL?

I search the help for T-sql, still don't know how to convert a number, for example 12345 to a string with formating like 12,345

Thanks for your help.




Join WebHost4Life.com

0
free
7/7/2006 9:38:56 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
361 Views

Similar Articles

[PageSpeed] 28

The best place to do such formatting is in the front end, not at the database level.

That being said, you could use a combination of the CONVERT and CAST functions (see CAST and CONVERT) to cast the number as a money type, then convert it to a varchar, and then strip off the decimal point and 2 0's at the end:
DECLARE @test int
SELECT @test = 12345
SELECT REPLACE(CONVERT(varchar(50), CAST(@test AS money), 1),'.00','')

Or, you could make use of a general-purpose UDF like this one from Novick Software's newsletter, which gives you a lot more flexibility and the code is reusable: Formatting a Number
 

Terri Morton
Engagement Manager, Neudesic

How to ask a question

0
tmorton
7/8/2006 3:23:10 PM
Reply:

Similar Artilces:

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

converting sql to MS SQL
I'm trying to unload a SQL Anywhere database to a MS SQL 6.5 database. The SQL produced from SQL Anywhere is not at all compatible. Is there an easy way of moving a database from SQLA to MS SQL darrell@texas.net Look at PowerDesigner from Powersoft. I can reverse engineer SQLA and create the MSSQL Server DDL for you. Dave Wolf Sybase Professional Services Darrell Fuller wrote: > I'm trying to unload a SQL Anywhere database to a MS SQL 6.5 database. > The > SQL produced from SQL Anywhere is not at all compatible. Is there an easy > way of moving...

Is is possible to run a .SQL file on SQL Server without converting file contents to a string?
Is it possible to run a .SQL file without converting the contents of the file to a string and then executing the string? Is it possible to run or execute the file? Thanks You can use the .sql file as an input file to ISQL using the -i switch "Kevin Wiebe" <kevin.wiebe@riseinc.com> wrote in message news:BjSh5G7GCHA.196@forums.sybase.com... > Is it possible to run a .SQL file without converting the contents of the > file to a string and then executing the string? Is it possible to run or > execute the file? > Thanks > > ...

what's difference between Accesss DataBase and Sql Sever about Sql String(or Command),Sql StoreProcedure ?
i am being dirty to Access DataBase from Sql Sever Database for my new work.But the sql string of Access sounds like a little different,can i use  the sql string of SqlSever for Access database,too?another question is: Does Access DataBase support Sql StoreProcedure??? when i worked in Access2000 ,did not see any about StoreProcedure,but i download a file named AccessHelper.cs  , some function of it looks like support StoreProcedure,Does it?  i want to fly ... Hi dkzeng ,Your first question     The string of both sqlsever and acce...

viewing sql string passed into sql server
I have a stored proc that has several parameters. (using SQL server) i call this proc and add the parameters etc and execute it etc the problem is that how can i see the string that is being passed to the db? eg the calling command? cheers Use the SQL Profiler. You can set it to monitor, and set filters as to what gets monitored. You can save the output in a file or a database as well.Starting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog hi douglas.reilly i did think of that, i was woundering if there a way of viewing it in the debug envir...

Convert SQL Express to SQL server or Access
Is there anyway to convert an SQL Express database to SQL server or Access format? From one SQL Server to another is called moving a database and I have covered all the ways you can do in the FAQ below, sorry I don't use Access but you could use DTS to move it to Access, how to get the limited DTS is covered in the second FAQ.  Hope this helps. http://forums.asp.net/thread/1454694.aspxhttp://forums.asp.net/thread/1458004.aspxKind regards,Gift Peddie...

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf files ...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi,Basically i built a webpage with Login and it's working well from my local machine.Right now, i'm using Database Publishing Wizard. the problem is how do i convert.MDF files to .SQL 2005 to get my database publish in the internet? thanks  Place your .MDF file in the App_Data directory, change the connection string accordingly and then publish your web site. ----------------------------------------------------------Please click Mark As Answer if this helped in solving your problem.  Please click "Mark As Answer" if this hepled in solving your problem. ...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf file...

sql or my sql query
hi,in my database  i have the two tables...1)programs                                2)reservedin the programs...two fields 1)program id           2)maxseats................these details wil be entered by adminin the reserved table  two fileds ..1)PRogramid        2)statusmy requirement is .. i need the available seats..meansif any body is intersted in  any program...they wil select the program...then status becomes approved(1)..then i need the o/p as ...

Convert Sql Server 2005 to Sql Server 2000
I have to downgrade a eCommerce database from Sql Server 2005 to Sql Server 2000 due to hosting server's support compatibility. Almost all features in the original (2005) version are available in 2000. Any recommendations as on an easy conversion? Thanks a lot. -Yubo It's not possible to easily/directly convert a SQL Server 2005 database to SQL Server 2000.  I learned this the very hard way.  My suggestion would be to find a new host.Terri MortonEngagement Manager, NeudesicHow to ask a question I have the same issue, in that I developed an ASP.Net 2.0 application using SQL Se...

convert SQL 2005 express .mdf to SQL 2005
Hi Forum, I need some good info regards remote host requirements. I dev web app using VS 2005 express edition and SQL Server Management Studio express. Everything is ready to transfer to host running SQL 2005. My ? do I have to convert my SQL 2005 express .mdf to a SQL 2005 file type. (hosting company state I do, then save as .bak) much appreciate good data, Paul    A mdb file is Access based, an mdf file is the data file of SQL Server. They are not convertible. You will have to import the data from access or export / upsize from access to make them stored on the server.....

Converting an Int to a String in SQL
Is there (is there) a command in t-sql to convert an Integer value to a string value?  Thank you, in advance for your help. select convert(nvarchar, intfield)Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). Syntax for CAST: CAST ( expression AS data_type [ (length ) ]) Syntax for CONVERT: CONVERT ( data_type [ ( length ) ] , expression [ , style ] )http://msdn.microsoft.com/en-us/library/ms187928.aspxA fine is a tax for doing wrong. A tax is a f...

Web resources about - how to convert a number to string in SQL? - asp.net.sql-datasource

List of converts to Buddhism - Wikipedia, the free encyclopedia
Ajahn Brahm (born 1951), Religious teacher and student of the late Thai monk Ajahn Chah . Currently he is the abbot of the Bodhinyana Monastery, ...

Facebook Timeline For Pages: 8 Million Converts, 29 Million To Go
... reach to 98 percent of users who liked its page, as well as to double its engagement rate, during a 28-day period. Dr. Pepper hasn’t yet converted ...

Facebook stock roundup: Execs offload more stock, directors convert shares
... Bowles, the former co-chair of the now-defunct National Commission on Fiscal Responsibility and Reform, and Reed Hastings, Netflix CEO, converted ...

How to Convert Leads Into Buying Customers - The 9 Step Sales Process EVERYONE Should Use
... School of Business in Toronto on the topics of Sales and Entrepreneurship. I shared with them the sales process that I find How to Convert Leads ...

Bitcoin : Should I convert my savings to Bitcoin?
Answer (1 of 7): You should think of this question as "Should I invest all my savings in Bitcoin?", and not "Should I have my savings denominated ...

Coordinates - Calculate and Convert a Position on the App Store on iTunes
Get Coordinates - Calculate and Convert a Position on the App Store. See screenshots and ratings, and read customer reviews.

Catholics should not convert Jews, says Vatican, in push against anti-Semitism
... 50 years since the Vatican's repudiation of the concept of Jewish guilt for Jesus' death.  Vatican City: Catholics should not try to convert ...

Today’s apps gone free: BlockBear, Stock Grader, PDF Smart Convert and more
Block ads and other annoying content, take the emotion out of investing, and convert almost anything into a PDF with todays collection of apps ...

Ford patents rear wheel that converts into a unicycle
Filed under: Government/Legal , Green , Ford , Green Driving , Motorcycle , Electric Ford is thinking about allowing drivers to remove a rear ...

How to convert your old VHS tapes to DVD with this software
Remember those old VHS tapes you have sitting in the corner? Convert them into DVDs with this affordable software so you can easily watch them ...

Resources last updated: 1/19/2016 1:50:30 PM