Dividing Bytes By 1 Million To Get Megabytes In Select

Feb 13, 2005

Hello!





I have a table that contains a field containing the total bytes for a file. I am displaying the information in a datagrid but need to display the information in MB. If I divide by 1,000,000 in my select statement as such:SELECT cs_fileSize / 1000000 AS MB, cs_fileSize


FROM t_client_spotsI get the following results:





MB | cs_filesize


1 | 1899602


1 | 1782281





I would like the results to be:





MB | cs_filesize


1.89 | 1899602


1.78 | 1782281





Any suggestions?





Thanks in advance!!

View 2 Replies


ADVERTISEMENT

DB Engine :: Deleting 1 Million Records From Transaction Table Of 10 Million Data On 24/7 Environment

Jun 12, 2015

I have a requirement to delete 1 Million records from a table having 10 Million data and it's being queried on 24/7 basis (don't have a downtime). how can I achieve that?

View 13 Replies View Related

Dividing

Jun 20, 2007

I have four sum statements in a procedure and I want to add two more fields that divide thismonthdeclines / thismonthsales, and prevmonthdeclines / premonthsales. I have tried a few ways and I just cant get the syntax right. Can someone help..


ALTER PROCEDURE dbo.sp_MTD_Declines

(@prevMonthStart datetime, @prevMonthEnd datetime, @thisMonthStart datetime, @thisMonthEnd datetime)

as

select

sum(case when O.orderdate between @prevMonthStart and @prevMonthEnd then D.orderlinetotal else 0 end ) as PrevMonthSales,

sum(case when O.orderdate between @thisMonthStart and @thisMonthEnd then D.orderlinetotal else 0 end ) as ThisMonthSales,

sum(case when O.orderdate between @prevMonthStart and @prevMonthEnd then case when O.orderstatus = 'CC Declined' then O.ordertotal end else 0 end) as PrevMonthDeclines,

sum(case when O.orderdate between @thisMonthStart and @thisMonthEnd then case when O.orderstatus = 'CC Declined' then O.ordertotal end else 0 end) as ThisMonthDeclines



from exigo_data_sync.Orders O INNER JOIN
exigo_data_sync.OrderDetail D ON O.OrderID = D.OrderID

where O.orderdate >= @prevMonthStart

View 11 Replies View Related

Dividing Counts

Sep 19, 2007

I'm sorry if someone has already posted this but I've looked through a few pages to see if someone had already posted and I couldn't find anything. Anyways, I have two counts and I would like to divide them to get a percentage. Basically I would like to see a percentage of how many tickets are overdue. Here's my SQL:

select count(*)[No. of Tickets Overdue],
case
when sum(datepart(dd,getdate() - j.report_date))>= pt.due_hours then 'Over Due'
when sum(datepart(dd,getdate() - j.report_date))>= pt.due_hours then 'Over Due'
when sum(datepart(dd,getdate() - j.report_date))>= pt.due_hours then 'Over Due'
when sum(datepart(dd,getdate() - j.report_date))>= pt.due_hours then 'Over Due'
end [Ticket Status]
from whd.priority_type pt
inner join whd.job_ticket j on pt.priority_type_id = j.priority_type_id
where j.status_type_id = '1' and j.deleted = '0' and not j.priority_type_id = '5' and not j.priority_type_id = '6'
group by pt.due_hours
order by pt.due_hours desc
COMPUTE SUM(count(*))

select count(*)[Count2]
from whd.job_ticket jt
where jt.status_type_id = '1' and jt.deleted = '0'-- and not jt.priority_type_id = '5' and not jt.priority_type_id = '6'
--COMPUTE [No. of Tickets Overdue]/[Count2]

I know this isn't correct but basically the commented line at the bottom is what I want to do. I've only been doing SQL statements for a few months now, so I know its novice but any help is appreciated.
Thanks in advance.

View 7 Replies View Related

Dividing Up Result Set Into 4 Groups

Feb 1, 2007

Hello,

I am trying to take my result set and dividing up the results into 4 equal
groups

I have included my code and a partial result set.
All of your input and help is appreciated as I am new at this


select accounts.id, sum(trans.amount) as 'income'
from jom.dbo.accounts
join jom.dbo.trans
on trans.accounts_id = accounts.id
where trans.amount > 0
group by accounts.id


id income
471098.00
471108.00
4711112.00
4711216.00
4712516.00
4712610.00
471278.00
4712816.00
4712942.99
47142139.00
471438.00
4714452.00
471455.00
47159625.94
4716075.00
471618.00
471628.00
4717625.00
4717720.00
4717816.00
4717928.00
4719274.94
47193248.00
47194176.00
4719539.99
4719616.00
4720916.00
4721046.00
47211177.00
472128.00
4722644.00
47227178.99
4722824.97
4722927.00
4724216.00
4724324.00
472448.00
4724549.00
4724670.00
4725919.95
4726010.00
4726122.00
4726240.00
472768.00
4727768.00
472788.00
472798.00
4729316.00
4729456.00
4729510.00
4729663.00
4730934.00
4731126.00
4731218.00
4732624.00
4732716.00
47328215.00
473298.00
4734319.95
4734419.95
4734519.95
4734642.00
4735962.00
4736016.00
4736175.00
4736240.00
473638.00
4737619.95
4737719.95
4737824.00
4737913.00
473938.00
4739498.95
4739563.95
4739625.95
4741021.00
4741147.00
47412229.00
474138.00
4742618.00
474278.00
4742860.00
4742944.95
4744393.00
4744420.00
4744510.00
4744618.00
4746028.00
4746116.00
4746232.00
4746348.00
4747622.00
47477110.00
4747816.00
4747936.00
474808.00
4749398.95
4749460.00
4749524.00
4749698.00

View 2 Replies View Related

Dividing Two CAse Statements

Mar 9, 2007

How do I divide these two case statements:

1. sum(CASE WHEN o.sap_apc_indic is null THEN wip.wip_oth_exp_amt
ELSE 0
END) Markup,

2. sum(CASE WHEN o.sap_apc_indic is not null THEN wip.wip_oth_exp_amt
ELSE 0
END) AP,

View 1 Replies View Related

Help Dividing Two Values From Different Tables.

Jul 14, 2007

Hi, I am completly new in ASP , but, due the necessity of the production in the company I work, I need
urgently to learn do deal with scripts and SQL.

I did a script that shows on the production screen the consume tax of the gas instantly on time and it

worked. Now I have to do a table formed by the DIVISION of a valor V from one table by the valor V in

another table, mas the values must be taken at the same time do give me the gas consumed by ton produced.

Explaining in details:

I have two tabels:

1 - PDE#HD#Consumption#RP_Consumption_Gas
2 - PDE#HD#SpeedCurves#Productivity

Inside each of these tables, there are two columms with the same name for both -> V, T. The V columm of the

table PDE#HD#Consumption#RP_Consumption_Gas gives me the cas consumed and the V table of

PDE#HD#SpeedCurves#Productivity the productivity. The V1/V2 graph must be ploted in a 24 hours period. What

happens is that if I do it for 24 houres, I mean, 1 day, the graph is ploted completly wrong in time! If I

do the same thing, but using only one columm, not the division by another, it works! Why this is happening ?

What is wrong with the following script ?? I need to know the answer for this as fast as possible! If you

need more details, I will give.

The script:

DayForm = Request.Form("D1")

Dim hoje
Dim dia

If DayForm = "" OR DayForm = 0 Then hoje = true

If hoje Then _
Set rs = conn.Execute("SELECT

convert(varchar,PDE#HD#Consumption#RP_Consumption_Gas.T,108),(PDE#HD#Consumption
#RP_Consumption_Gas.V/PDE#HD#SpeedCurves#Productivity.V) As Consumo FROM

PDE#HD#Consumption#RP_Consumption_Gas INNER JOIN PDE#HD#SpeedCurves#Productivity ON

PDE#HD#Consumption#RP_Consumption_Gas.T = PDE#HD#SpeedCurves#Productivity.T WHERE

PDE#HD#Consumption#RP_Consumption_Gas.T > DATEADD(dd, -1, GetDate()) ORDER BY

PDE#HD#Consumption#RP_Consumption_Gas.T") _
Else _
Set rs = conn.Execute("SELECT

convert(varchar,PDE#HD#Consumption#RP_Consumption_Gas.T,108),(PDE#HD#Consumption
#RP_Consumption_Gas.V/PDE#HD#SpeedCurves#Productivity.V) As Consumo FROM

PDE#HD#Consumption#RP_Consumption_Gas INNER JOIN PDE#HD#SpeedCurves#Productivity ON

PDE#HD#Consumption#RP_Consumption_Gas.T = PDE#HD#SpeedCurves#Productivity.T WHERE

PDE#HD#Consumption#RP_Consumption_Gas.T > convert(date, DATEADD(dd, " & DayForm & ", GetDate())) AND

PDE#HD#Consumption#RP_Consumption_Gas.T < convert(date, DATEADD(dd, " & DayForm+1 & ", GetDate())) ORDER BY

PDE#HD#Consumption#RP_Consumption_Gas.T ")

View 2 Replies View Related

Dividing Two Count() Results

Jul 20, 2005

Just a quick question, how do I divide the results of these two queriestogether ?(select count (*) as ontime from schedule where actualarrivaldate <=estimatearrivaldate)(select count (*) as total from schedule)Thanks for any helpRobert

View 2 Replies View Related

Dividing Subtotal In A Matrix

Jan 12, 2007

I want to divide the subtotal of a matrix. Can I do ?

View 1 Replies View Related

Percentage, Dividing By Zero … #Error … ???

May 6, 2008

Hi
1: I€™m trying to get a percentage value (Left to Target) but I€™m getting €œ#Error€? in the Preview.
This is what I have:
=IIF(Fields!SalesTarget.Value Is Nothing , 0, ((Fields!Rev.Value)-(Fields!SalesTarget.Value))/(Fields!SalesTarget.Value))
How can this not work?
I looked at a previous thread in here but I couldn€™t get anything from there L
Kind Regards

View 12 Replies View Related

Dividing Integers To Produce A Percentage

Aug 27, 2003

I'm embarassed I haven't figured this out already but here goes.

Lets say you need a percentage from dividing two integers for example

"select 2000/4000"

This will produce a zero and I'm assuming that is because of the datatypes involved (the values are coming from columns where the datatype is int)

I've tried converting the values to decimal types but I keep getting overflow erros unless I use very small values.

As always, thanks VERY MUCH for the kind advice.

View 2 Replies View Related

T-SQL (SS2K8) :: Dividing A Number With Remainders

Jan 29, 2015

SQL Server (TSQL) how to divide a number by either 2,3,4, or 6 and spreading it across that number of rows depending on what we are dividing the number by where it comes back to the original number...That is confusing I know so let me break it down...

Bill for 143.23 that will be paid out through 2 months...When you divide that by 2, you come back with 71.62, but if you multiply that number by 2, you come back with 143.24, not the amount for the bill...the end result has to be 71.62 for month1 and 71.61 for month2...Basically when there is a remainder, that has to be applied to the first month...

143.23:
Month1 = 71.62
Month2 = 71.61

Another example...Same amount but have to divide by 6

143.23
Month1 = 23.88
Month2 = 23.87
Month3 = 23.87
Month4 = 23.87
Month5 = 23.87
Month6 = 23.87

View 9 Replies View Related

Dividing The Sale Amount By Month

Jul 3, 2006

Hello,

I want to process a row from a source table by dividing the sales amount in that row over the period of the sale by month.

For instance if an item is sold for 500$ and it's duration is 5 months from 1/15/2004 till 6/15/2004, I want to divide the sale amount by month as follows:

Month 1: 50$

Month 2: 100$

Month 3: 100$

Month 4: 100$

Month 5: 100$

Month 6: 50$

I know I can create a script component and do the calculation for each month and insert 6 records in the fact table for each row in the source table, where each record holds the amount for the corresponding month. However I was wondering if there is another technique that utilizes the components of SSIS to do it more efficiently.

Thanks,

Grace

View 4 Replies View Related

Dividing Two Numbers Truncates After 4 Decimal Places

Dec 19, 2000

I have two fields - both defined as money.
When I divide them, SQL Server truncates the result after the 4th decimal point.
So SQL Server says: 370.45 / 3,391,517.85 = 0.0001
I want to achieve: 370.45 / 3,391,517.85 = 0.00010922837... etc.
The field the result is going into is defined as decimal(20,18)

I've tried using "cast(1stmoneyfield as decimal(20,18)) / cast(2ndmoneyfield as decimal(20,18)) as dividednumber", but SQL Server reports back errors about null values and Arithmetic overflow and terminates.

I'm at a loss as to how to solve the problem. Any suggestions please?

View 1 Replies View Related

T-SQL (SS2K8) :: Dividing Two Rows Within CASE Statement

Jul 28, 2014

I was given the task to come up with a result set based on certain criteria:

Please add one row for each offer code

1) Opt-in rate by offer code: This can be calculated by dividing XXX Inventory with lead / XXX Inventory (A)

The report should read something like below:

Example result set:

Log Date: OfferLetter OfferCode DailyCount

2014-07-20 A XXX Inventory (A) 108
2014-07-20 A XXX Inventory with lead 54
2014-07-20 A XXX Inventory Opt-in Rate: 50%

There are 12 different groupings and OfferLetter A is just one of them.

Below is the code that is written to date:

DECLARE @Start datetime = DATEADD(day, DATEDIFF(day, 0, GETDATE() - 8), 0)
DECLARE @End datetime = DATEADD(day, DATEDIFF(day, 0, GETDATE() - 1) + 1, 0)
DECLARE @Today datetime = DATEADD(day, DATEDIFF(day, 0, GETDATE() - 1), 0);

SELECTDT.OfferCode, DT.OfferCodeDesc
INTO#tempOfferCodes

[Code] ....

The issue I'm having is that the values I need to divide by are in fact, a result set from the CASE statement. It's been a long time since I've done anything like this.

View 2 Replies View Related

T-SQL (SS2K8) :: Dividing Two Values Of Same Column / Grouping

Aug 4, 2014

I'm trying to divide two values from separate rows. Each row is a separate UNION statement.

2014-08-03 00:00:00.000NKBB (N) - Total Offers 1218 UNION (A)
2014-08-03 00:00:00.000NKBB (N) - With Lead 301 UNION (B)
2014-08-03 00:00:00.000NKBB (N) - Without Leads 917 UNION (C)

In the below example, I would like to divide KBB (N) - With Lead (UNION (B)/KBB (N) - Total Offers UNION (A)

What would be the best way to accomplish this?

View 1 Replies View Related

Dividing A Large Flat File Into Small Files

Jul 16, 2007

Hi ,

Is there any method by which I can divide the large flat file into certain number of small files keeping the header in each of the sub files?

Regards,

Prash

View 4 Replies View Related

SQL Server 2012 :: Create A New Column By Dividing 2 Columns In The Query?

Mar 12, 2015

I have the following query that displays 2 values. I want to add a column with the percentage ([Providers With Security]

/ProviderTotal) * 100
SELECT (SELECT COUNT(DISTINCT NPI) FROM HS140_Rpt_Tmp_ForSummary WHERE Market = s.Market) AS ProviderTotal,COUNT(DISTINCT NPI) AS [Providers With Security]
FROM HS140_Rpt_Tmp_ForSummary s
WHERE s.[Security] = 'Yes'
GROUP BY Market

How can I do this?

View 1 Replies View Related

Max Bytes Per Row

Apr 25, 2001

SQL 7

One of my programmers brought an error to me that I need to get some clarification on ...

Its says:
The total row size (24301) for table xxxx eceeds the max number of bytes per row(8060). Rows that exceed the max number of bytes will not be added.

Thoughts ...

View 2 Replies View Related

0 Bytes

Dec 26, 2001

Hi,

I used to write the data in a database throught the component. Few days it worked fine and suddenly one day it showed the database is suspect and the file size is 0 bytes but actually is should have written lots of data.

But i have the datafile which shows zero bytes and when i try to attach it it gives an error:

Server: Msg 823, Level 24, State 6, Line 1
I/O error 38(Reached the end of the file.) detected during read at offset 0000000000000000 in file 'D:EorderdatabasePritamdbeorderpritamdb_Data.mdf'.

Connection Broken

Can anyone tell y is this. And it would be really if anyone can tell how to recover the data. The only thing which i have now is the data file which shows zero bytes.

Thanks.

View 9 Replies View Related

WTF.. Bytes Per Row???

Aug 24, 2005

I tried to ALTER TABLE calendar NOCHECK CONSTRAINT ALL and I got this error:

Warning: The table 'messages' has been created but its maximum row size (8321) exceeds the maximum number of bytes per row (8060). INSERT or UPDATE of a row in this table will fail if the resulting row length exceeds 8060 bytes.

I'm not too certain what this error means so I manually deleted the records in this table. I got the same error.

View 3 Replies View Related

How Many Bytes Were Taken Per Row?

Dec 2, 2007

How to count how many bytes were taken per row in certern table?
Which method is the most correct and directly?
Thanks

View 3 Replies View Related

Memory Available Bytes

May 30, 2008

I'm taking a look at a server to optimize it and need a better understanding of the Memory Available Bytes.

If the graph is showing this @ 100 is that a good or bad thing.
Articles are saying it shouldn't be below 4MB...
Can anyone elaborate?

thanks,
Jonathan

View 1 Replies View Related

I Only Want The First 50 Bytes Of The Filed :(

Apr 6, 2004

My database has chinese characters in.
Eventually I need to only get the first 50 bytes of the data field, but somehow, I use len('==data==',50), it would catch 50 chinese characters which make 100 bytes ...
can anyone help me?
Thank you very much no matter what the result is ;)

View 1 Replies View Related

75 Million Row Update???

Apr 17, 2003

Hi all,
I have a table with approx 75 million rows of names and addrersses in it that I am trtying to update...so far the update is running 5 hours and with no end in sight...a liitle background is that this is running on a quad zion 500 with 3 gb ram ands one 145 gb drive (boooo) without improving the hardware needs can i improve the performance...I have indexed all the where fields that i read on and only update the table but once or twice a month, but I do daily selects by zip or county (all indexed) i even have a composite key on phone and zip...

i have heard of horizontal partioning but i always thought that was reserved for archiving old transactional data that rarely gets read on....

when i performed a trace there are plenty of reads but no writes...is this normal during an update like this...

i have been running this proc for the past 7 HOURS!!!....any help is appreciated, since all i have is time at this point....

THANKS!!!!

--Set rowcount to 100000 to limit number of updates
--performed in each batch to 100K rows.
Set rowcount 100000

--Declare variable for row count
Declare @rc int
Set @rc=100000

While @rc=100000
Begin

Begin Transaction

--Use tablockx and holdlock to obtain and hold
--an immediate exclusive table lock. This unusually
--speeds the update because only one lock is needed.
Update [2000] With (tablockx, holdlock)
set [source] = '2000'

--Get number of rows updated
--Process will continue until less than 10000
Select @rc=@@rowcount

--Commit the transaction
Commit
End

View 5 Replies View Related

Converting Bytes To String

May 3, 2007

Hi guys,I'm currently trying to insert image into my SQL db. 
I have tried a number of methods that were posted online, and so far
with no luck.My current code reads:                     Dim conn As New Data.SqlClient.SqlConnection()                    conn.ConnectionString = ConfigurationManager.ConnectionStrings("MainDBConnection").ToString                    conn.Open()                    Dim cmd As New Data.SqlClient.SqlCommand("SP_SAVEImage", conn)                    cmd.CommandType = Data.CommandType.StoredProcedure                    Dim sImageName As New Data.SqlClient.SqlParameter("@sImageName", Data.SqlDbType.VarChar, 50)                    sImageName.Value = sImageName                    Dim sImageType As New Data.SqlClient.SqlParameter("@sImageType", Data.SqlDbType.VarChar, 50)                    sImageType.Value = fileType                    Dim sImageData As New Data.SqlClient.SqlParameter("@sImageData", Data.SqlDbType.Image, uploadedFile.Length)                    sImageData.Value = uploadedFile                    cmd.Parameters.Add(sImageName)                    cmd.Parameters.Add(sImageType)                    cmd.Parameters.Add(sImageData)                    Dim reader1 As Data.SqlClient.SqlDataReader                    reader1 = cmd.ExecuteReaderRunning
through debug, everything runs up until the last line, where an error
is caught saying : Failed to convert parameter value from a
SqlParameter to a String I reckon it's to do with the input sImageData being input as a byte array - but I can't seem to find a way around it. Any help greatly appreciated!!

View 1 Replies View Related

Maximum Number Of Bytes Per Row

Aug 1, 2001

if SQL SERVER 2000 only allow 8060 bytes per row, then how can it store images or CLOB data? Is there a way that would let us change the maximum number of bytes per row? Any help would be greatly appreciated. Thanks.

View 1 Replies View Related

REPLICATE() Beyond 8000 Bytes

May 18, 2007

I'm wondering if there's a way to use the string function replicate() to produce an output greater than 8000 bytes. From the documentation REPLICATE returns a varchar of max 8000 but I'm told there's a way to stop this restriction.

My mentor has been giving me tasks to try and accomplish and for this one I'm to create a stored procedure with no limitations, however I'm stuck at this replicate() problem.

Any help or guidance would be great.

Thanks

View 1 Replies View Related

Calculating Number Of Bytes

Jun 7, 2004

Hi,

We are trying to get a rough estimate of the size of the warehouse in terms of number of bytes. Now I understand that when I say char(2) datatype requires 2 bytes of memory. If this is correct then how many bytes does the following data type need -

1. smalldatetime
2. decimal(14,2)
3. decimal(12,2)
4. int
5. smallint.
6. decimal(9,0)

Also can you explain the byte allocation for a varchar column. Say varchar(20) for example.

Any help is appreciated.

Vivek

View 3 Replies View Related

CONVERT BYTES TO MB Script?

Jan 29, 2015

I have a field that is stored in bytes in sql2008 R2. I need a simple script that will convert this field to MB & round up. I'm not able to find anything but complicated functions a.

View 9 Replies View Related

How Much Bytes Needed In Sql Server

Jun 13, 2007

Hi i want to know how much bytes will sql server take to store asingle alphabet like "a". i need to know similarly for all data types(including images).here i am doing a application where i need topredict the amount of space required in sql server to store the userfed dynamic data.Give me a handy solution.Regardsvisu

View 5 Replies View Related

Bytes Transfered Over The Wire

Oct 15, 2007

does anyone know when you sync (for the first time), if the snapshot is sent to the remote/client side compressed or uncompressed? i'm not talking about the resulting .sdf file size. i'm talking about the actual bytes that are tranfered or the wire.

thanks,

bryan

View 4 Replies View Related

DB Design :: How Many Bytes Use A Varchar

Nov 3, 2015

I have a varchar(900) which means that I can use 900bytes, so if I am not wrong if the character is unicode, y only can use 450 because each character need two bytes.I have a databease with a column that use the intercalation general_latin_CI_AI, but I don't know if this intercalation use 1byte per character or use 2bytes per character.How can I know how many bytes need a character of a varchar column?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved