Very Simple Getting Started Question About Formatting Data
Jan 2, 2008
Okay, I know this is a very simple question, but here it is.
I have a select statement that returns a value such as: 9902.7400000000.
In the select statement it just selecting Value. In the select statement, can I format the output to be with just two decimal places? I know I should know the answer to this and how to do it, but thank you for any help.
View 3 Replies
ADVERTISEMENT
Apr 14, 2004
Embarrassed to ask but nevertheless here i go:
I have a SQL like this:
select sum(qty)
from tblXYZ
The results is displayed as (for example) 123456789.56
I want the results to be displayed as 123,456,789.56 (i.e. use the currency or the comma format; whatever it's called).
Please help
View 9 Replies
View Related
Jul 10, 2006
What is the equivalent SSIS expression for this C expression to format an unsigned integer by padding it with leading zeros?
sprintf(publ_doc_id, "%010u", id)
View 1 Replies
View Related
Jun 19, 2007
Hello,
I have noticed that for one of my data-flows, the process is really long during the phase "the final commit data insertion has started".
To be accurate, the process is fast until it reaches this phase. It happens often when I load millions of lines.
The extraction is done from a database SQL Server 2005 to a database SQL Server 2005, on the same server (with the SQL Server native provider).
I used a SQL Server destination but I have tried with an OLE DB destination and it is the same situation.
Why the process could be so long during this phase?
There is a way to optimised my package to avoid that?
Any idea is welcome.
Thanks.
Guillaume
View 6 Replies
View Related
Mar 13, 2001
Does anyone familiar with a tool or a quick way to put apostrophes and commas around some values, so they could be used in a query ? Example, if I have a bunch of zip codes such as:
10001
10003
10009
54321
89043
etc
Let's say I have a couple of hundreds of them. I need to be able to see them as -
'10001','10003','10009','54321','89043' etc
Appreciate very much your time.
Ivan
View 3 Replies
View Related
Apr 12, 1999
Hello Everyone,
I have been requested to take a number of columns and concatenate them into one column with a specifc format/layout. For example I need to take this, (noting all columns are of different datatypes:
col_1 col_2 col_3 col_4 col_5 col_6 col_7
PK #1 John Doe 123 Elm Street Anywhere NM 55660
#2
#3
etc..
...and create this on a different table (noting col_2 is of datatype "text":
col_1 col_2
PK #1 John Doe
123 Elm Street
Anywhere NM 55660
#2
#3
etc..
Can this type of formatting be done?
I know how to concatenate data and use the convert function, but how do you add in CR-LF to get the proper formatting??
Any help would be greatly appreciated.
Troy
View 1 Replies
View Related
Sep 8, 2006
I am new to php/MySQL and am working on an online manual. The data is divided into Title and Content. The title is easy as it is one line but the content is meant to be in a number of paragraphs.
The Content field is currently set as "blob" and the text comes out as just one paragraph. Wha can I do to get paragraphs etc into the text?
Thanks.
View 1 Replies
View Related
Dec 5, 2006
Hi all,
I have data in a SQL Server table of type varchar(6). Each record in the column is a number of 2, 3 or 4 digits.
e.g. 22, 130, 1000, 60 etc...
I want to update all the values in the column so that they are always 4 characters long and have leading zeros.
e.g. 0022, 0130, 1000, 0060 etc...
How could I go about doing this?
Thanks
Kabir
View 2 Replies
View Related
Aug 18, 2004
Hi all,
I have a question about using FOR XML and sp_makewebtask. This (see below) is a simplified example where I have a table with 3 columns, the two first columns hold varius data and the third column (Subdata3) holds duplicated data.
My question is: Is it possible to transform the hierachy of data (see "Prefered XML output" for details) when transforming from SQL to XML using either FOR XML EXPLICIT or by using some sort of more advanced sp_makewebtask template (or some other technique perhaps)? And if, how? Any help welcome!
Cheers,
Christian
----------------------
--- sp_makewebtask ---
EXEC sp_makewebtask
@outputfile = c: empoutput.xml,
@query = 'SELECT Subdata1, Subdata2, Subdata3 FROM Data WHERE Subdata3 = X FOR XML AUTO, ELEMENTS',
@templatefile ='c: emp emplate.tpl'
--- c: emp emplate.tpl ---
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<%begindetail%>
<%insert_data_here%>
<%enddetail%>
</Data>
--- c: empoutput.xml ---
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<Subdata>
<Subdata1>455</Subdata1>
<Subdata2>12312</Subdata2>
<Subdata3>1</Subdata3>
</Subdata>
<Subdata>
<Subdata1>435345</Subdata1>
<Subdata2>675</Subdata2>
<Subdata3>1</Subdata3>
</Subdata>
<Subdata>
<Subdata1>133323</Subdata1>
<Subdata2>976</Subdata2>
<Subdata3>1</Subdata3>
</Subdata>
</Data>
--- Prefered XML output ---
<?xml version="1.0" encoding="UTF-8"?>
<Data Subdata3="1">
<Subdata>
<Subdata1>455</Subdata1>
<Subdata2>12312</Subdata2>
</Subdata>
<Subdata>
<Subdata1>435345</Subdata1>
<Subdata2>675</Subdata2>
</Subdata>
<Subdata>
<Subdata1>133323</Subdata1>
<Subdata2>976</Subdata2>
</Subdata>
</Data>
View 1 Replies
View Related
Jun 27, 2007
Hello,
I'm looking for solutions to a formatting problem.
I have two stand alone textboxes on a report body that I would like to have display side by side with very little white space between them.
Example: TextBox 1 contents (variable length) = "Muddy Waters"
Textbox 2 contents (variable length) = "B.Sc"
Current display: Muddy Waters B.Sc
Desired display: Muddy Waters B.Sc
Here is my problem.
Simple concatenation of values into 1 textbox would work if the font size and font family were the same for both textboxes; unfortunately this isn't the case. The font size and family for each textbox is different. Is there a richtext control I can place on the report and load with preformatted rich text?
Any suggestions would be appreciated.
Thanks,
Roy M
View 5 Replies
View Related
Jul 17, 2001
Hi, How would I convert(or format) money data type, so the output will be like: 123,456.78 or 12,345.67
(In other words how would I insert a comma which separates hundred from thousand...)
Thanks a lot,
Andy
View 1 Replies
View Related
Apr 3, 2014
I am working with extracting data from a SAP database, and I would like to perform some 'visual formatting' on the returned data. Because the SQL code that I am writing will be used in a custom Report it is not possible for me to use '3rd Party' formatting tools. Furthermore because the database is hosted on an MS SQL 2008 R2 RDBMS it is not possible to use the IIF() function.
Here is a sample of the data that I am getting back at the moment. URL...Here is how I would like the data to be returned (with the exception that the blue lines will ideally be blank cells). URL...
I have come to believe that I should be using the ROW_NUMBER() function, along with the OVER() function and possibly the 'partition by' keywords.Here is my original code -
Code:
select
td.ItemCode as 'Item Code'
, td.Dscription as 'Item Description', td.Quantity as 'Order Qty'
, titm.OnOrder as 'PO Qty'
, th.CardCode as 'BP Code', th.CardName as 'BP Name'
, th.DocNum as 'Sales Order Number'
, tsp.SlpName as 'Sales Person'
, twhs.WhsCode as 'Whs Code'
, isnull(tbloc.BINLABEL, '') as 'BIN Label', isnull(cast(tbloc.QUANTITY as nvarchar(20)), '') as 'BIN Qty'
code]...
Notice above that I only see the 'Seq' and no other data. How can I go about modifying this code so that I see all of the data columns I desire? If I further 'refine' the above, by adding case statements and the individual columns that I want to see (as opposed to using the * wildcard) I get a long list of error messages.
View 9 Replies
View Related
Oct 9, 2014
I need to return a single column (Name.company) but I want the data returned to be viewed in multiple columns.
First is that possible? Second if so how?
My data looks like this:
University X
University X - 1
University X - 2
University X - 3
College X
College X - 1
College X - 2
College X - 3
Cmty College X
Cmty College X - 1
Cmty College X - 2
etc.
How can I get it to return only:
University X
College X
Cmty College X
View 20 Replies
View Related
Jan 23, 2007
I have a matrix where i'm trying to have the report select the maximum value in the data area (not including the subtotals) and bold that value.
month
day1
day2
day3
day4
total
Jan
10
15
5
12
42
Feb
5
8
3
11
27
Total
15
23
8
23
69
I'm sure i will have to use the IIF function in conjunction with the InScope function.
However i'm unsure on how to isolate to the max value and make sure the Inscope function does not affect the totals.
any idea's are appreciated.
View 3 Replies
View Related
Mar 11, 2004
Hi
I have two questions : 1) Linking SQL Server Databases
2) Data Formatting like InputMask
1) I want to know if there is a way to link two seperate SQL server databases (it's tables) within the same server (local server). I created one Global database - with clients, etc. tables. The reason I did it like this is that I have to handle three seperate invoices databases, but using the same clients, etc. tables to get their information from. I used MS Access like this, linking Clients, etc tables from the Clients Database with the three other Databases. It worked fine but now I need some new features like setting the InvoiceNumber to something different, eg . 04/0001 for this year and then 05/0001 for next year. My Access databases can't change this numbers - it's just a autonumber I used. I know some Visual Basic code can make a change like perhaps adding a new column like InvYear and then adding it together with InvoiceNumber to get the Invoice Number, but I want to change it to SQL Server because I want to learn how SQL Server works. I am just starting out and not doing courses.
2) The other thing is I want to know if there is some feature in SQL Server to make data input easier, like a InputMask in Access where you can let a text column be formatted as you want. Eg. for a telephone number, it can store it in the format you made; like (011) 123 4567, not like you typed it : 0111234567.
I would appreciate some help.
Thank you
Corné
View 3 Replies
View Related
Oct 22, 2015
I need to export some Database data into a text file. My Query looks like this:
SELECT Category1, Category2, Category3
FROM dbo.tbl1
WHERE Category1 = 'JP-4'
AND Category2> 4;
This works fine to get the data, however there is some html formatting in the table entries such as
`<p>,</p>,
,</br>` etc.
So ideally I need to remove those when exporting the data to the text file. I've tried to do it with a simple replace query but that didn't work. I've also got an issue with line splits and would need to remove the ( ).
The Data format is something like this:
Category1: JP-4
Category2: 4
Category3:<p>Neque porro quisquam est qui dolorem ipsum quia dolor</p> <p>amet, consectetur, adipisci velit</p>
Category4:<p>Neque porro quisquam est qui dolorem ipsum quia dolor</p>
I got it to work like this with the replace function:
SELECT REPLACE(REPLACE("PHOTOGRAPHS",'<p>',''),'</p>','')
FROM dbo.khia_tbl
WHERE Category1= 'JP-4'
AND Category2> 4;
But the issue is that I've got 15 columns in total and that I need to do it for several different tags for each column so
,
</br>,
as well as "" and different spaces so that would be a lot and I thought there must be a better/more efficient way of doing it...
View 1 Replies
View Related
Jul 9, 2013
'17686568 - Bill Statement - 11/16/2006 - Stm. Date - 10/27/2006'
Above is the data string that I am trying to pull the information from. Here is the function I'm currently using:
cast(substring(c.itemname,charindex('Bill Statement - ',c.itemname)+18,10) as varchar)
...which gives me what i want most of the time, but beacuse the date is not equally formatted through out the database and the date can look like 5/4/2012 and using the above formula it will show up as 5/4/2012 -
So my question is how can i trim off the dash part when the data shows up like 5/4/2012 - ?
View 3 Replies
View Related
Oct 16, 2007
I have a report that has ten pages (essentially ten different reports). Each page has one, large main chart and then three smaller charts stacked on top of each other off to the right. The layout is in landscape. When I render the report in Reporting Services, the layout looks fine. If I export it to Adobe, it is also fine. However, when the report is emailed as a PDF attachment, the main chart on each page is completely missing. Has anybody experienced something simliar? I was having issues with the layout, and decreasing the height of each page fixed everything, but created this new problem. I am using Adobe 7.0. Thank you.
View 1 Replies
View Related
Nov 8, 2015
Data Label formatting issue in SSRS Databar? Refer the below screenshot:
View 3 Replies
View Related
Jun 20, 2015
Please find below my query and result , how to display [Total Service Time ] in HH:Min format (Currently values in minutes)
Query:Â
SELECT Â DISTINCT Â dbo.sectn_dept.sectn_sc AS Customer,
MONTH(dbo.incident.date_logged) AS Month_Number, DATENAME(month,
dbo.incident.date_logged) AS Month, YEAR(dbo.incident.date_logged) AS Year,Â
dbo.incident.incident_ref PM_ref,
dbo.product.product_n "Product",
[Code] ....
 Â
Result:
Need to Display [Total Service Time] in below Format:
But Some values are repeating ....
View 2 Replies
View Related
Feb 28, 2008
Is it possible to format a single cell with many lines of data. For instance, if I wanted to list an entire address in one cell like this:
123 Main St.
Apt. 1
Austin, TX 78759
Would that be possible through some kind of special formatting? Maybe with <br /> or something like that?
View 1 Replies
View Related
Jun 18, 2008
I am attempting to update contact data that is displayed in a form. Unfortunately the followiing code that runs off the button click event does not seem to work or I am misssing something to make it fire. I get no errors but the data does not get updated. What am I missing? Thanks.Private Sub btn_Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Submit.Click
Dim strConnection As StringDim cn As SqlConnection
Dim sql As String
strConnection = ConfigurationSettings.AppSettings("ConnectionString")cn = New SqlConnection(strConnection)
sql = "UPDATE vw_BS_IssuerContacts SET ContactLastName = @ContactLastName, ContactFirstName = @ContactFirstName, ContactTitle = @ContactTitle, ContactEmail = @ContactEmail, ContactPhone = @ContactPhone, Address1 = @Address1, Address2 = @Address2, Address3 = @Address3, Country = @Country, ZipCode = @zipCode, AccessLevel = @AccessLevel WHERE IssuerCode = @IssuerCode"Dim UpdateCommand As New SqlCommand(sql, cn)
UpdateCommand.Connection = cn
UpdateCommand.CommandText = sqlUpdateCommand.Parameters.Add(New SqlParameter("@IssuerCode", Lbl_IssuerCode.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@ContactLastName", txt_Lname.Text))UpdateCommand.Parameters.Add(New SqlParameter("@ContactFirstName", txt_Fname.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@ContactTitle", txt_title.Text))UpdateCommand.Parameters.Add(New SqlParameter("@ContactEmail", txt_Email.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@ContactPhone", txt_Phone.Text))UpdateCommand.Parameters.Add(New SqlParameter("@Address1", txt_Address.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@Address2", txt_Address2.Text))UpdateCommand.Parameters.Add(New SqlParameter("@Address3", txt_City.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@Country", txt_Country.Text))UpdateCommand.Parameters.Add(New SqlParameter("@ZipCode", txt_zipCode.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@AccessLevel", Lbl_currAccessLevel.Text))
'UpdateCommand.Parameters.Add(New SqlParameter("@AccessLevel", SqlDbType.Char, 2).Value = txt_CurrAccessLevelSelectedValue))UpdateCommand.Parameters.Add(New SqlParameter("@UserName", txt_Username.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@infopw", txt_pw.Text))UpdateCommand.Parameters.Add(New SqlParameter("@Company", txt_IssName.Text))
'do the update
cn.Open()
UpdateCommand.ExecuteNonQuery()
cn.Close()
End Sub
View 1 Replies
View Related
Mar 31, 2004
hi,
when to use varchar and
when to use Nvarchar....
could any one tell please....
thanks
View 3 Replies
View Related
Dec 27, 2007
Greetings all,
I have two databases and need to transfer some data from one to the other based on the "employee_Number".
"Table 1 and 2" both have a complete listing of employees but in "Table 1" certain columns are empty. I need to see if "Table 2" has got data in those columns and if yes import them to the "Table 1" based on the "Employee Number"
What is the simplest way to do this. both are on SQl server.
please Help
Thanks in advance........
View 3 Replies
View Related
Oct 9, 2007
Hi,I am developing an ASP.NET app that uses SQL Server 2005.I have 1 single connection string to the database that is defined in my web.config.In my backend VB code in the App_Data folder ( and so not related to any aspx page ) , i wish to access my database.Here is the code I use: Dim query As New SqlDataSource query.ConnectionString = ConfigurationManager.ConnectionStrings("MainConnectionString").ConnectionString query.InsertCommand = "INSERT INTO myTable(data, time) VALUES (...) query.Insert() All i want to is whether this is the correct and fastest way to access my database. Is it ?? Thanks for your help,roxie
View 2 Replies
View Related
Feb 13, 2006
If I am trying to import data from an Access database into my tables via transact sql how and what are my first steps. I'm a newbie just trying to learn. Do I do via an insert statement and if so how do I do that. My SQL tables have no data in them and I would also have to make sure that can convert the datatypes from Access to SQL. Thanks in advance for anyhelp given.
View 4 Replies
View Related
Mar 22, 2007
So these are a couple different interpretations I've made of a statement that needs to return students name's with the OSOS field in the attendcode code column of the attendance table on todays date with an attendance.aperiod column equal to 4.
This first one returns no results at all when I should get about 7 rows or so.....
Select Student.name,
attendance.studentid,
attendance.attenddate,
attendance.aperiod,
attendance.attendcode
from Attendance, Student
where AttendDate >= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0)
And AttendDate < DateAdd(Day, DateDiff(Day, 0, GetDate()), 0) + 1
And aperiod = '4'
And AttendCode = 'OSOS'
AND student.name = Attendance.studentid
This one is returning all of the names in the database 6 times each.
Select Student.name,
attendance.studentid,
attendance.attenddate,
attendance.aperiod,
attendance.attendcode
from Attendance, Student
where AttendDate >= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0)
And AttendDate < DateAdd(Day, DateDiff(Day, 0, GetDate()), 0) + 1
And aperiod = '4'
And AttendCode = 'OSOS' order by name
I think something is messed up with my WHERE control but I cant figure it out... Any help is greatly appreciated!
View 4 Replies
View Related
Sep 21, 2006
I am looking at building some very simple web pages that attach to a SQL Server database. They will just display simple data from predefined views on the SQL Server.
A link to examples would be fantastic. I have done similar before to attach to data from access. Its the connection and data retrieval I need help with.
Thanks.
Mark.
View 4 Replies
View Related
Jul 30, 2007
Hello,
I have a table similar to the following (XYZ). I would like to write a select statement that will return the count of the unique items for each user that also happen to be less than 1 year old. The less than one year old part is rather easy dateadd(year, -1, getdate()), but I seem to be having a hard time figuring out how to get my desired result without using subselects. Any help greatly appreciated. Thanks in advance - Dan.
So my goal results are:
User Count
Dan 2
Dave 1
Table XYZ
ID User Item Value Date
1 Dan 1 20 5/5/2007
2 Dan 1 30 6/5/2007
3 Dave 2 25 6/1/2007
4 Dan 2 22 5/1/2007
5 Dan 3 23 5/1/2006
View 6 Replies
View Related
Jul 26, 2007
Hi
I have a simple data control task that has an OLE source and OLE target.
the source is a SQL query that returns 200m records this is then written straight out to a table. I have used a data flow task so that I can chunk up the inserts rather than using a INSERT INTO.....SELECT FROM.
I have ran it multiple times and it hangs once it reaches 18,961,020 records.
there is no locking on the database and I have even restarted the SQL instance to ensure that there was nothing else contending for resource.
I have changed gthe buffer size and rows per buffer to 100m and 100,000. Now it hangs before the 18.9m mark presumably becuase of the increased buffer size.
I notice that the SELECT statement continues to clock up io and cpu cycles but the BULK insert process has gone.
any ideas on where to start looking?
Thanks for your help
Marcus
View 16 Replies
View Related
Mar 9, 2008
Could any one help me in
Writing code/query to export simple English text data from MSSQL Sever2000 to FoxPro2.6 dbf
aamir_net68@yahoo.com
View 1 Replies
View Related
Aug 25, 2007
I want to create a procedure where nextvisitdate is a cloumn for date
so when I passed variable @nextvisitdate then which data type I have touse with it.
CREATE PROCEDURE sp_salesman_nextvisitdate
@salesman varchar (50),
@nextvisitdate date (50)
As
Select * from Entry Form
WHERE
@salesman = salesman
AND
@nextvisitdate = nextvisitdate
GO
You Have to Loss Many Times to Win Single Time
View 3 Replies
View Related
Jul 20, 2005
Hi, all:I'm a newbie trying to understand the concept of referential integrity anddealing with Primary and Foreign Keys. I'm sure mine is a simple problem...I've created 3 tables as follows:MemberTable-----1 Member ID (Primary key)2 Member Name3 etc...FoodsTable-----1 Food ID (Primary key)2 Food NameMemberFoods-----1 Member ID (Foreign key)2 Food ID (Foreign key)Now, I've just learned about referential integrity and all that, and this ismy first foray into creating primary/foreign keys, linking tables, etc. (soI'm assuming the above tables are fine). What I don't understand is this:if I have a (checkbox) form from which members can choose their favoritefoods, how do I insert that data? For example:Food Form-----Which of these are your favorite foods:1) Steak2) Chicken3) Potatoes4) etc...If I want to insert, let's say, 'Steak' and 'Chicken', do I have to first doa query on my Foods table to retrieve the Food ID's for Steak and Chicken,and then do an "insert" using those ID's into my MemberFoods table? (I amusing the actual Food Names (not ID's) as values on my form.) If so, cansomeone please share the SQL for retrieving and then inserting?I don' t know...maybe I'm overcomplicating the issue, but it just seems likea lot of extra work to maintain a "linking table" of foreign keys.Thanks for the help.
View 1 Replies
View Related