什么是仅插入新记录的最佳方式 [英] What's the best way to insert new records only

查看:73
本文介绍了什么是仅插入新记录的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



每天早上,.NET应用程序都会下载一个文件,其中累积数据需要附加到SQL Server表中。这个程序需要识别以前没有插入过的
记录(有一个唯一的标识符

字段)并且只插入那些。此外,我必须重用我们的更新类,

它基本上可以使用SqlDataAdapter .update方法更新任何表。所以

我必须排除批量插入,DTS等...

我认为我别无选择,只能先将所有记录加载到temp中。表格

然后只将新记录(不存在的地方)附加到真实记录中。表。可以

有人想到更好的解决方案吗?


谢谢。

解决方案

< blockquote> itterating所有下载的记录,每个运行一个

ExecuteScalar()来查看唯一标识符是否已经存在,如果没有

插入它? (分机呼叫太多了?)


Picho

" LP" < lp@a.com>在消息中写道

新闻:O5 ************** @ TK2MSFTNGP14.phx.gbl ...


每天早上.NET应用程序都会下载一个包含累积数据的文件,这些文件需要附加到SQL Server表中。该程序需要识别以前未插入的记录(有一个唯一的
标识符
字段)并且只插入这些记录。此外,我必须重用我们的类更新,
它基本上可以使用SqlDataAdapter .update方法更新任何表。
所以
我必须排除批量插入,DTS,等......
我认为我别无选择,只能将所有记录首先加载到临时表格中,然后只将新记录(不存在的地方)附加到真实"表。谁能想到更好的解决方案?

谢谢。



> (分数太多了吗?)

嗯......是的!


Picho < SP ******** @ telhai.ac.il>在消息中写道

news:u5 ************** @ TK2MSFTNGP12.phx.gbl ...

itterating所有下载的内容记录,为每一个运行一个
ExecuteScalar()来查看唯一标识符是否已经存在,如果没有,请插入它? (过多的db调用?)

Picho

" LP" < lp@a.com>在消息中写道
新闻:O5 ************** @ TK2MSFTNGP14.phx.gbl ...


每天早上,.NET应用程序都会下载一个包含累积数据的文件,而这些数据需要附加到SQL Server表中。该程序需要识别以前未插入的记录(有一个唯一的
标识符
字段)并且只插入这些记录。此外,我必须重用我们的类更新,
它基本上可以使用SqlDataAdapter .update
方法更新任何表。所以
我必须排除批量插入,DTS等...
我想我别无选择,只能将所有记录首先加载到temp
表中
然后只将新记录(不存在的地方)附加到真实记录中。表。
有人能想到更好的解决方案吗?

谢谢。



只是想一想,您是否已将数据作为XML文档发送给b b $ b,例如使用OPENXML语句的存储过程

插入数据?


问候,

Joakim


Picho写道:

itterating如何所有下载的记录,每一个运行一个
ExecuteScalar(),看看是否已经存在唯一标识符,如果没有插入它? (过多的db调用?)

Picho

" LP" < lp@a.com>在消息中写道
新闻:O5 ************** @ TK2MSFTNGP14.phx.gbl ...


每天早上.NET应用程序都会下载一个包含累积数据的文件,这些文件需要附加到SQL Server表中。该程序需要识别以前未插入的记录(有一个唯一的
标识符
字段)并且只插入这些记录。此外,我必须重用我们的类更新,
它基本上可以使用SqlDataAdapter .update方法更新任何表。
所以
我必须排除批量插入,DTS,等......
我认为我别无选择,只能将所有记录首先加载到临时表格中,然后只将新记录(不存在的地方)附加到真实"表。谁能想到更好的解决方案呢?

谢谢。



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.

解决方案

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**************@TK2MSFTNGP14.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********@telhai.ac.il> wrote in message
news:u5**************@TK2MSFTNGP12.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**************@TK2MSFTNGP14.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**************@TK2MSFTNGP14.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.




这篇关于什么是仅插入新记录的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆