Showing posts with label rows. Show all posts
Showing posts with label rows. Show all posts

Friday, March 30, 2012

Log of rows inserted/updated/deleted

HI, I am wondering if it is possible to retreive this information without using row count transform. Can I get the # of rows inserted/updated or deleted by destination from the log?

Thank you,
Ccote

An OnInformation event is raised by the data-flow task when data flows into a destination. This has free text which contains the number of rows. You would have to parse that information out of the text within the OnInformation eventhandler. See here for more details: https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=372847&SiteID=1

-Jamie

Log not needed

In an unusual circumstance I face, there is a very large log created by the
importation of several million rows from another database. After importing,
the database will never change. As the original database is still
available, and the import could be re-run at any time from this, neither
logging nor backup is desirable. The whole thing can be recreated whenever
needed (the original from which the import is done is backed up).
This is for Express.
What facilities are available to either suppress the log or remove it? It
is several gigabytes long after the import.
As I understand it, SELECT queries to search the database will not create
any log, and it will never grow again. Right?
Tom EllisonWhat about a read only DB?
Lookup ALTER DATABASE (Transact-SQL) in BOL it is covered in that section
http://sqlservercode.blogspot.com/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message
news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
> In an unusual circumstance I face, there is a very large log created by
> the importation of several million rows from another database. After
> importing, the database will never change. As the original database is
> still available, and the import could be re-run at any time from this,
> neither logging nor backup is desirable. The whole thing can be recreated
> whenever needed (the original from which the import is done is backed up).
> This is for Express.
> What facilities are available to either suppress the log or remove it? It
> is several gigabytes long after the import.
> As I understand it, SELECT queries to search the database will not create
> any log, and it will never grow again. Right?
> Tom Ellison
>
>|||Dear SQL:
In BOL "ALTER DATABASE/Transact SQL Reference":
READONLY
Specifies the filegroup is read-only. Updates to objects in it are not
allowed. The primary filegroup cannot be made read-only. Only users with
exclusive database access can mark a filegroup read-only.
My log is in the primary filegroup, right? Is there more to it than this?
Tom Ellison
"SQL" <sqlservercode@.gmail.com> wrote in message
news:u8IUAOgRGHA.4608@.tk2msftngp13.phx.gbl...
> What about a read only DB?
> Lookup ALTER DATABASE (Transact-SQL) in BOL it is covered in that section
> http://sqlservercode.blogspot.com/
>
> "Tom Ellison" <tellison@.jcdoyle.com> wrote in message
> news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
>|||Would it not be possible and simple to shrink the log to nothing after the
initial import? It could then function normally, meaning nothing would
happen in ordinary operations, just searching the database.
Tom Ellison
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message
news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
> In an unusual circumstance I face, there is a very large log created by
> the importation of several million rows from another database. After
> importing, the database will never change. As the original database is
> still available, and the import could be re-run at any time from this,
> neither logging nor backup is desirable. The whole thing can be recreated
> whenever needed (the original from which the import is done is backed up).
> This is for Express.
> What facilities are available to either suppress the log or remove it? It
> is several gigabytes long after the import.
> As I understand it, SELECT queries to search the database will not create
> any log, and it will never grow again. Right?
> Tom Ellison
>
>|||Yes you could issue a BACKUP LOG (logname) WITH TRUNCATE_ONLY followed by a
DBCC SHRINKFILE command
http://sqlservercode.blogspot.com/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message
news:%232PoWZgRGHA.1780@.TK2MSFTNGP12.phx.gbl...
> Would it not be possible and simple to shrink the log to nothing after the
> initial import? It could then function normally, meaning nothing would
> happen in ordinary operations, just searching the database.
> Tom Ellison
> "Tom Ellison" <tellison@.jcdoyle.com> wrote in message
> news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
>|||> My log is in the primary filegroup, right?
No, the log isn't in any file group. The file group concept is only for data
files.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message news:Ou1avWgRGHA.1160@.TK2MSFTNGP09.ph
x.gbl...
> Dear SQL:
> In BOL "ALTER DATABASE/Transact SQL Reference":
> READONLY
> Specifies the filegroup is read-only. Updates to objects in it are not
> allowed. The primary filegroup cannot be made read-only. Only users with
> exclusive database access can mark a filegroup read-only.
> My log is in the primary filegroup, right? Is there more to it than this?
> Tom Ellison
>
> "SQL" <sqlservercode@.gmail.com> wrote in message
> news:u8IUAOgRGHA.4608@.tk2msftngp13.phx.gbl...
>|||I'd go for first simple recovery mode, then shrinking the log file after the
import (tips and hints
at http://www.karaszi.com/SQLServer/info_dont_shrink.asp). Then set the data
base (not filegroup) to
read-only.
Also, see if you can do the import minimally logged. Some import mechanisms
allow for this (BCP,.
BULK INSERT, DTS if you do it right etc).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Tom Ellison" <tellison@.jcdoyle.com> wrote in message news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.ph
x.gbl...
> In an unusual circumstance I face, there is a very large log created by th
e importation of several
> million rows from another database. After importing, the database will ne
ver change. As the
> original database is still available, and the import could be re-run at an
y time from this,
> neither logging nor backup is desirable. The whole thing can be recreated
whenever needed (the
> original from which the import is done is backed up).
> This is for Express.
> What facilities are available to either suppress the log or remove it? It
is several gigabytes
> long after the import.
> As I understand it, SELECT queries to search the database will not create
any log, and it will
> never grow again. Right?
> Tom Ellison
>
>|||Dear Tibor:
Thank you very much.
Now, on site, we do not have tools for production. There is only SQL
Express and Access. The OS is not a server. Am I correct to rule out BCP
and DTS on this basis?
As the source is an Access MDB, I'm thinking BULK INSERT does not apply.
Can BULK INSERT be done from an mdb? If so, what parameters allow for this?
Assuming there may not be an extra 3 gigabytes of disk space on every
computer where we need to install this, it would be a good thing just not to
create this log.
What would it do if the log were on a NULL device?
Is there any hope?
Tom Ellison
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evtXglgRGHA.5908@.TK2MSFTNGP14.phx.gbl...
> I'd go for first simple recovery mode, then shrinking the log file after
> the import (tips and hints at
> http://www.karaszi.com/SQLServer/info_dont_shrink.asp). Then set the
> database (not filegroup) to read-only.
> Also, see if you can do the import minimally logged. Some import
> mechanisms allow for this (BCP,. BULK INSERT, DTS if you do it right etc).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Tom Ellison" <tellison@.jcdoyle.com> wrote in message
> news:eU7tOIgRGHA.2224@.TK2MSFTNGP10.phx.gbl...
>|||Tom Ellison (tellison@.jcdoyle.com) writes:
> Now, on site, we do not have tools for production. There is only SQL
> Express and Access. The OS is not a server. Am I correct to rule out BCP
> and DTS on this basis?
DTS (or SSIS), yes, BCP no. BCP comes with SQL Server Express.

> As the source is an Access MDB, I'm thinking BULK INSERT does not apply.
> Can BULK INSERT be done from an mdb? If so, what parameters allow for
> this?
I don't know much about Access, but as Access, or rather Jet, is a
DB engine, an MDB file is likely to have more than data. I mean it
has things like index pointers etc. So the answer would be no.

> Assuming there may not be an extra 3 gigabytes of disk space on every
> computer where we need to install this, it would be a good thing just
> not to create this log.
> What would it do if the log were on a NULL device?
I seriously doubt that SQL Server would let you get away with it.
The first step is to set the database to simple recovery. In this mode,
SQL Server will truncate the log regularly. Since the log cannot be
truncated past the oldest open transaction, it can still become huge,
if your transactions are huge. To keep down the log size, you could import
data in batches, of, say, 1000 rows at a time. Bowever, this is more
complex, and the import will take longer time. (You don't say how you
run the import, but I assume that you run queries against a linked
server.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Dear Erland:
Thanks very much. Pretty much what I expected.
The initial installation step is to import about 10 million rows. This is
going to create a HUGE log file, for which we have no use. I doubt the 10
gigabytes will be available on the destination computers. Some are just
laptops.
We have just spent several hours investigating various problems this is
causing.
We are first defragmenting the hard drive. However, creating both database
and log are causing a fratmented database file. In addition, as I said,
there will likely not be enough space for both on the hard drive.
Right now we are using Access to append the rows to SQL Express. It is far
too slow. We drop the indexes ahead of time, append a few million records,
and recreate the indexes. It is taking hours to do this. I'd really like
to find a way to speed this. The best approach of which I know is to create
a linked server to the Access database. I've always done that before using
EM. When I use this in QA:
sp_addlinkedserver @.server = 'MyJet', @.srvproduct = '', @.provider =
'Microsoft.Jet.OLEDB.4.0',
@.datasrc = 'C:\Documents and Settings\All Users\Documents\TData.mdb'
I cannot then access the Jet table:
SELECT * FROM MyJet...TData
Server: Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "MyJet"
reported an error. Authentication failed.
Server: Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider
"Microsoft.Jet.OLEDB.4.0" for linked server "MyJet".
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "MyJet" returned
message "Cannot start your application. The workgroup information file is
missing or opened exclusively by another user.".
I used the same script then to try to create the linked server in SQL 2000,
and it fails similarly. However, I then opened that SQL 2000 linked server
using EM and changed:
Linked Server Properties
Security
For a login not defined in the list above, connections will:
Be made without using a security context
Or course, EM doesn't work at all with Express, and it is only by solving
this in Express that it will accomplish anything toward my goals. I've also
tried to see what T-SQL EM is generating to do this, but with no success.
If I knew just what EM was doing, it might fix me up pretty quickly, right?
The SQL 2000 linked server then commenced working. I expect this relates to
setting one of the options in the linked server, but I have not been able to
isolate it.
If I could find how to fix my linked server within Express, then I am hoping
to see improved performance in the appending.
My goals are to improve this performance and to also prevent the creation of
a useless multi-gigabyte log, which may not fit within the available disk
space, and which horribly fragments the creation of the database. I may
just break down and size the database in advance.
Please make any recommendations that occur to you. And thank you very much,
again.
Tom Ellison
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns97856F8AD31CYazorman@.127.0.0.1...
> Tom Ellison (tellison@.jcdoyle.com) writes:
> DTS (or SSIS), yes, BCP no. BCP comes with SQL Server Express.
>
> I don't know much about Access, but as Access, or rather Jet, is a
> DB engine, an MDB file is likely to have more than data. I mean it
> has things like index pointers etc. So the answer would be no.
>
> I seriously doubt that SQL Server would let you get away with it.
> The first step is to set the database to simple recovery. In this mode,
> SQL Server will truncate the log regularly. Since the log cannot be
> truncated past the oldest open transaction, it can still become huge,
> if your transactions are huge. To keep down the log size, you could import
> data in batches, of, say, 1000 rows at a time. Bowever, this is more
> complex, and the import will take longer time. (You don't say how you
> run the import, but I assume that you run queries against a linked
> server.)
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx

Friday, March 9, 2012

Log Errors but Continue to Load Data?

Hello,

In my SSIS package I am trying to import a .csv flat file with about 170,000 rows of data with 75 columns (I know this is rather large). I would like to create a SSIS package that loads ALL of the rows of data into a table. This table has it's fields defined (such as money, float, varchar, datetime, etc). I want the data to load to this table even if there is a conversion error converting any field. When the data is loaded to this table, any fields that couldn't be converted should be set to null. Of the 75 columns of data, there are MANY columns that could be invalid.

For example, if the flat file contains the value "00/00/00" for my "PaidDate" field, I would want all of the other fields to be populated and the value for this particular record's "PaidDate" field to be null.

It would also be nice if I could trap any of the fields that caused a problem and log them along with the row.

I know that SSIS supports the "Redirect Row" method for handling data, but in my case, I don't want to redirect it. I want to continue to load it, just with a null value.

Is there an easy way of doing this (i.e. perhaps by using the Advanced Editor for the Flat File Source and setting something in the Input/Output columns)? I really don't want to create a Derived Column or Data Conversion transformation for every field that needs to be converted (b/c there are 75 columns to maintain this for).

I know if I import this file to an Access 2003 database, it imports the data fine and logs any conversion errors to an "_ConversionErrors" table. I am basically looking for this same behavior in SSIS, without having to maintain 75 columns.

TIA

There is one other way I can think of. If you change the output columns of your source to be the same data type as your destination and select "ignore" for all errors then it will just cause that one column of the row to not be loaded into the data flow. Of course you have no way of determining which rows these are and you also have to manage the metadata by hand so I doubt you'd be much better off than a data conversion transformation.|||

Thanks Brent!

I actually started going down this path (convert from the flat file source) right after I posted my initial question. It stinks that I can't identify the rows. I tried to do make the conversion/truncation for each "redirect" to another route and then join them all back together using the UNION ALL, but it turns out you only get three values back from the ErrorOutput columns...A stream reader, an error code, and an error column. This isn't enough information to get back to the row that caused the error without some nasty parsing logic I assume.

Would be nice if there was a way to funnel that stream and re-create a row from it!

Thanks again!