Showing posts with label choice. Show all posts
Showing posts with label choice. Show all posts

Friday, March 23, 2012

Formatting output from a SQL table

I have used a Winform textbox to enter the following data into a nvarchar field:

1. Choice number one

2. Choice number two

3 Choice number three

etc.

How do I print out the nvarchar field to look like the above? Can I do this in Reporting Services or something else? Thanks.

why can't you? have you tried?

doesn't sound difficult.

|||You could use the ReportViewer control in your application, create a report in local mode and use a datatable as the data source for the local report.sql

Wednesday, March 7, 2012

format output as scientific notation (was "sql 2000 question")

SELECT membername, outputval
case when choice = 0 then outputval else null end as outputval
from MyDatabase
group by membername, outputval

how to format outputval:
if outputval < 40000
format outputval as:
5 - 5.78 - 6.9 - 6,778 - 4,567.8 - 12,456.78 - etc.
if outputval >= 40000
format it as a scientific.I would strongly suggest that you do the formatting at either the web server (using PHP), or better yet at the client (possibly using Javascript). This would allow you to use locale specific information that isn't usually available to SQL Server.

If you really have to format the output at the SQL Server, it could be done using a SQL UDF that called xp_sprintf or other related tools. This means that every query will need to be formatted using the locale of your SQL Server, which is usually a huge problem for application globalization.

-PatP