Showing posts with label huge. Show all posts
Showing posts with label huge. Show all posts

Friday, March 23, 2012

question about log file size when alter Huge table

I have the next question, and i would like to hear what do you think
about, and if is there a better solution for "my problem"

here is the question, I have a huge table with 60GB of data (image
files). The problem happen always when i try to ALTER the structure of
the table. For example I change a field char(3) to char(4)...the
sqlserver then performs the "alter table" command...that must be
something similar than "insert into the new table + drop the actual
table" and for that I need about 60GB o space for my LOG file, and
takes hours to complete the operation.

Is this the only way to alter a single field in my table??

I would like to heard you opinions...Thanks..

ALberto"Gordowey" <albertoiriarte@.gmail.com> wrote in message
news:1130717670.681491.136070@.g47g2000cwa.googlegr oups.com...
> I have the next question, and i would like to hear what do you think
> about, and if is there a better solution for "my problem"
> here is the question, I have a huge table with 60GB of data (image
> files). The problem happen always when i try to ALTER the structure of
> the table. For example I change a field char(3) to char(4)...the
> sqlserver then performs the "alter table" command...that must be
> something similar than "insert into the new table + drop the actual
> table" and for that I need about 60GB o space for my LOG file, and
> takes hours to complete the operation.

Sounds about right.

> Is this the only way to alter a single field in my table??

Well, you might be able to ADD a new column to your table, that might work
better. (especially if it has no default).

Or, it might be easier to BCP the data out, truncate the table, BCP the data
in.

(in this case I don't think native format would work so you'd have to
experiment.)

> I would like to heard you opinions...Thanks..
> ALberto|||Gordowey (albertoiriarte@.gmail.com) writes:
> I have the next question, and i would like to hear what do you think
> about, and if is there a better solution for "my problem"
> here is the question, I have a huge table with 60GB of data (image
> files). The problem happen always when i try to ALTER the structure of
> the table. For example I change a field char(3) to char(4)...the
> sqlserver then performs the "alter table" command...that must be
> something similar than "insert into the new table + drop the actual
> table" and for that I need about 60GB o space for my LOG file, and
> takes hours to complete the operation.

Yup, that's it.

> Is this the only way to alter a single field in my table??

Rather than having ALTER TABLE to all that under the covers, you could do
it your self. The twist is that then you can do the insert in batches,
and truncate the transaction log between the turns. (Simplest is to run
in simple recovery mode if you can.) When you compose the batches, use
the clustered index for the table, else selection of the batches may be
horribly slow.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Friday, March 9, 2012

Question about Converting Crystal syntax into SQL or VB

I'm having an issue with a date field in Access. I have imported data
from a database and the date field is a HUGE number rather than an
actual date. I have a formula from crystal reports to convert the
number into a date, but I;m not sure how to convert the crystal report
formula into a SQL or VB formula. the formula is below.
NumberVar Yyyy ;
NumberVar Mm;
NumberVar Dd;
Yyyy := Truncate ({CALL_HDW.CALLDAT_HDW} / 65536) ;
Mm := Truncate (({CALL_HDW.CALLDAT_HDW} - (Yyyy * 65536)) / 256);
Dd := Truncate ({CALL_HDW.CALLDAT_HDW} - (Yyyy * 65536) - (Mm * 256)) ;
Date (Yyyy, Mm, Dd)
I would appreciate any help!
Thanks!
JROn 3 Feb 2006 12:23:12 -0800, jennifer.rodgers@.fidessa.com wrote:

>I'm having an issue with a date field in Access. I have imported data
>from a database and the date field is a HUGE number rather than an
>actual date. I have a formula from crystal reports to convert the
>number into a date, but I;m not sure how to convert the crystal report
>formula into a SQL or VB formula. the formula is below.
>
>NumberVar Yyyy ;
>NumberVar Mm;
>NumberVar Dd;
>Yyyy := Truncate ({CALL_HDW.CALLDAT_HDW} / 65536) ;
>Mm := Truncate (({CALL_HDW.CALLDAT_HDW} - (Yyyy * 65536)) / 256);
>Dd := Truncate ({CALL_HDW.CALLDAT_HDW} - (Yyyy * 65536) - (Mm * 256)) ;
>Date (Yyyy, Mm, Dd)
>I would appreciate any help!
>Thanks!
>JR
Hi JR,
Try if this works for you:
SELECT DATEADD(year,
(CALLDAT_HDW / 65536) - 2000,
DATEADD(month,
(CALLDAT_HDW % 65536) / 256,
DATEADD(day,
CALLDAT_HDW % 256,
'19991231')))
Hugo Kornelis, SQL Server MVP