Hi,
Every morning a .NET application downloads a file with cumulative data which
needs to be appended to SQL Server table. This program needs to identify
records that have not been previously inserted (there's a unique identifier
field) and only insert those. Also I must reuse our class that does updates,
it basically can update any table by using SqlDataAdapter .update method. So
I have to rule out bulk inserts, DTS, etc...
I think I have little choice but to load all records first to a "temp" table
and then append only new records (where not exists) to a "real" table. Can
anyone think of a better solution?
Thank you. 16 1913
how about itterating all downloaded records, for each one run an
ExecuteScalar() to see if the unique identifier already exists and if not
insert it? (too many db calls?)
Picho
"LP" <lp@a.com> wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl... Hi,
Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously inserted (there's a unique identifier field) and only insert those. Also I must reuse our class that does updates, it basically can update any table by using SqlDataAdapter .update method. So I have to rule out bulk inserts, DTS, etc... I think I have little choice but to load all records first to a "temp" table and then append only new records (where not exists) to a "real" table. Can anyone think of a better solution?
Thank you.
> (too many db calls?)
Well... yeah!
"Picho" <SP********@tel hai.ac.il> wrote in message
news:u5******** ******@TK2MSFTN GP12.phx.gbl... how about itterating all downloaded records, for each one run an ExecuteScalar() to see if the unique identifier already exists and if not insert it? (too many db calls?)
Picho
"LP" <lp@a.com> wrote in message news:O5******** ******@TK2MSFTN GP14.phx.gbl... Hi,
Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously inserted (there's a unique identifier field) and only insert those. Also I must reuse our class that does updates, it basically can update any table by using SqlDataAdapter .update
method. So I have to rule out bulk inserts, DTS, etc... I think I have little choice but to load all records first to a "temp" table and then append only new records (where not exists) to a "real" table.
Can anyone think of a better solution?
Thank you.
Just a thought, Have you looked at sending the data as an XML-document
to for instance a stored procedure that uses the OPENXML statement to
insert data?
Regards,
Joakim
Picho wrote: how about itterating all downloaded records, for each one run an ExecuteScalar() to see if the unique identifier already exists and if not insert it? (too many db calls?)
Picho
"LP" <lp@a.com> wrote in message news:O5******** ******@TK2MSFTN GP14.phx.gbl...
Hi,
Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously inserted (there's a unique identifier field) and only insert those. Also I must reuse our class that does updates, it basically can update any table by using SqlDataAdapter .update method. So I have to rule out bulk inserts, DTS, etc... I think I have little choice but to load all records first to a "temp" table and then append only new records (where not exists) to a "real" table. Can anyone think of a better solution?
Thank you.
Write a BCP/DTS upload routine to get the data on the server. Next, write a
merge routine that executes an INSERT that adds the new rows using a WHERE
clause that has
... newID NOT IN (SELECT ID From YourTargetTable )
hth
--
_______________ _______________ ______
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
_______________ _______________ ____
"LP" <lp@a.com> wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl... Hi,
Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously inserted (there's a unique identifier field) and only insert those. Also I must reuse our class that does updates, it basically can update any table by using SqlDataAdapter .update method. So I have to rule out bulk inserts, DTS, etc... I think I have little choice but to load all records first to a "temp" table and then append only new records (where not exists) to a "real" table. Can anyone think of a better solution?
Thank you.
Well I hope you are aware that the dataAdapter also makes a single call for
each row?
"LP" <lp@a.com> wrote in message
news:OM******** ******@TK2MSFTN GP09.phx.gbl... (too many db calls?) Well... yeah!
"Picho" <SP********@tel hai.ac.il> wrote in message news:u5******** ******@TK2MSFTN GP12.phx.gbl... how about itterating all downloaded records, for each one run an ExecuteScalar() to see if the unique identifier already exists and if not insert it? (too many db calls?)
Picho
"LP" <lp@a.com> wrote in message news:O5******** ******@TK2MSFTN GP14.phx.gbl... > Hi, > > Every morning a .NET application downloads a file with cumulative data > which > needs to be appended to SQL Server table. This program needs to > identify > records that have not been previously inserted (there's a unique > identifier > field) and only insert those. Also I must reuse our class that does > updates, > it basically can update any table by using SqlDataAdapter .update method. > So > I have to rule out bulk inserts, DTS, etc... > I think I have little choice but to load all records first to a "temp" > table > and then append only new records (where not exists) to a "real" table. Can > anyone think of a better solution? > > Thank you. > >
Okay when the file is downloaded, you have all the data you need to work
upon in one shot.
My suggested options are -
Preference #1 - BCP/DTS package exported to VB, converted to VB.NET/C#.NET
using Interop.
Preference #2 - SqlXML used over Interop that ships with MDAC 2.7. Send in
an UpdateGram.
But now when you say that you "must reuse the class that does updates", then
you are already doing the best that can be done given your constraints. i.e.
row by row concurrency checks and insert/updates. The temp table approach
doesn't seem to have substantial benefit IMO.
- Sahil Malik http://codebetter.com/blogs/sahil.malik/
"LP" <lp@a.com> wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl... Hi,
Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously inserted (there's a unique identifier field) and only insert those. Also I must reuse our class that does updates, it basically can update any table by using SqlDataAdapter .update method. So I have to rule out bulk inserts, DTS, etc... I think I have little choice but to load all records first to a "temp" table and then append only new records (where not exists) to a "real" table. Can anyone think of a better solution?
Thank you.
LP,
I think that evaluating and redesigning the class that does the updates
would be the best way.
Just my thought
Cor
"LP" <lp@a.com> wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl... Hi,
Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously inserted (there's a unique identifier field) and only insert those. Also I must reuse our class that does updates, it basically can update any table by using SqlDataAdapter .update method. So I have to rule out bulk inserts, DTS, etc... I think I have little choice but to load all records first to a "temp" table and then append only new records (where not exists) to a "real" table. Can anyone think of a better solution?
Thank you.
As others have said....
I'd not use a .NET application in that way unless I really had to.
In other words, if the app does something to manipulate the table which
necessitates user intevention then maybe I'd reconsider.
This is an every day task so I'd schedule a job every day and use DTS.
I'd have an interface table in my database.
The job would delete the old stuff in there, import the file into the table,
run a stored procedure which just appended new entries.
If there was a problem with the process or a suspected problem then i can go
back and look at the data in that table and track it down easy.
I like easy.
--
Regards,
Andy O'Neill
It's amazing how few people actually attempted to answer your question.
Using a data adapter, you can specify any command you want to occur when a
row is inserted. Specify that command as a stored procedure call in SQL.
(Perfectly legal).
Now, in the stored proc, take in the row parameters. Check if the row
exists. If not, insert it.
It really is that simple.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"LP" <lp@a.com> wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl... Hi,
Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously inserted (there's a unique identifier field) and only insert those. Also I must reuse our class that does updates, it basically can update any table by using SqlDataAdapter .update method. So I have to rule out bulk inserts, DTS, etc... I think I have little choice but to load all records first to a "temp" table and then append only new records (where not exists) to a "real" table. Can anyone think of a better solution?
Thank you.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Altemir |
last post by:
I have a table in MS Access 2003 that contains records that I would
like to copy to the end of the table. There is one slight deviation
from just doing a straightforwared COPY, however, in that I want to
append the new records using different value of column 1.
Here's an example of what I'm talking about:
Values in in Table1 before "copy" operation:
Bill, 3200 Palm Blvd
|
by: allyn44 |
last post by:
HI--what I am trying to do is 2 things:
1. Open a form in either data entry mode or edit mode depending on
what task the user is performing
2. Cancel events tied to fields on the form if I am in edit mode.
The reason I want to do this is becasue when entering a new record the
form is entered in data entry mode and I have lots of stuff happening
upon entering and leaving fields. In edit mode I do not want the
events to fire.
|
by: Mike |
last post by:
I know this sounds strange but I am at a loss. I am calling a simple
funtion that opens a connection to a SQL Server 2000 database and executes
an Insert Statement.
private void AddMinimunWageStipen(string payrollid,double amount)
{
System.Data.SqlClient.SqlConnection cn = null;
System.Data.SqlClient.SqlCommand cm = null;
|
by: Danny Smith |
last post by:
Can anyone help?
I want to find the fastest way of inserting a large number of records
(50,000+) into a SQL Server database (using C#).
The records are held in memory and the options I can think of are:
1. Creating a DataSet in memory and then calling the
DataAdapter.Update(dataSet) method. This runs an Insert query for each row
and ends up being quite slow. Is there any way to insert a whole DataSet at
|
by: LP |
last post by:
Hi,
Every morning a .NET application downloads a file with cumulative data which
needs to be appended to SQL Server table. This program needs to identify
records that have not been previously inserted (there's a unique identifier
field) and only insert those. Also I must reuse our class that does updates,
it basically can update any table by using SqlDataAdapter .update method. So
I have to rule out bulk inserts, DTS, etc...
I think I...
| |
by: Jeff |
last post by:
For years I have been using VBA extensively for updating data to tables
after processing. By this I mean if I had to do some intensive processing
that resulted in data in temp tables, I would have VBA code that wrote the
results of that away to the db, either creating new records or updating
existing records, whichever was relevant. This may also include deleting
records.
Now I generally do this by opening a recordset on the source data...
|
by: Xah Lee |
last post by:
in March, i posted a essay “What is Expressiveness in a Computer
Language”, archived at:
http://xahlee.org/perl-python/what_is_expresiveness.html
I was informed then that there is a academic paper written on this
subject.
On the Expressive Power of Programming Languages, by Matthias
Felleisen, 1990.
http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
|
by: nano2k |
last post by:
Hi
Shortly, I keep invoices in a table.
Occasionally, someone will fire the execution of a stored procedure
(SP) that performs several UPDATEs against (potentially) all invoices
OLDER than a date that is supplied to the SP as a parameter.
The SP is usually a lengthy process (it takes at least 30 mins).
The problem is that SQL server 2000 Dev Edition doesn't allow me to
insert new invoices that are "younger", while the SP is executing....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |