如何避免SQL Procedural插入处理 [英] How to avoid SQL Procedural insert processing
问题描述
你好,我在这里需要一些帮助:我有一个结构表:
TableWithRecords(Id int,Field1 varchar,Field2 money,Field3 date,Field4 bit),
我有一个表格,表示每种数据类型为
TableForText(Text varchar,TextType),
TableForDates(日期smalldatetime,DateType),
TableForMONEY(金额金额,金额类型)和
TableForBIT(TORF BIT ,BitType)
我有程序插入上面的4个表中的每一个。
记录在TableWithRecords中,我调用程序:保存记录中的金额字段,记录中的日期字段,记录中的文本字段和记录中的位字段,然后我转到TableWithRecords中的下一条记录。
因此,我在一个表中有所有金额,一个表中有日期,一个表中的所有文本和一个表中的所有位 - 我有办法在需要时再次形成行。
有没有办法不使用while循环或游标进行处理?我不想逐行处理,因为它会减慢性能时间。任何帮助?
谢谢。
Hello, I need a little help here on my queries: I have a table with structure:
TableWithRecords( Id int,Field1 varchar,Field2 money , Field3 date ,Field4 bit),
and I have a table representing each data type as
TableForText(Text varchar, TextType),
TableForDates(Date smalldatetime, DateType),
TableForMONEY(Amount MONEY, AmountType) and
TableForBIT(TORF BIT, BitType)
I have procedure which insert into each of the 4 tables above.
For each record in TableWithRecords, I call the procedures: to save amount fields in the record, dates field in record, text fields in the record and bit fields in the record and then I go to next record in TableWithRecords.
So that I have all amounts in one table, dates in one table, all texts in one table and all bits in one table - I have a way to form the rows again whenever I want.
Is there a way to not use a while loop or a cursor to do the processing? I do not want to do a row by row processing since it will slow the performance time. Any help?
Thanks.
推荐答案
我实际上通过对常见类型使用联合操作来实现这一点与批量插入物结合使用。谢谢大家。
I actually accomplished this by using a union operation for common types in conjunction with a bulk insert. Thanks guys.
尝试BULK INSERT
http://technet.microsoft.com/en-us/library/ms188365.aspx
try BULK INSERT
http://technet.microsoft.com/en-us/library/ms188365.aspx
这篇关于如何避免SQL Procedural插入处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!