向接口插入记录
我已经设置了一个存储过程,用于将单个记录插入表中。这样做的原因是为了创建一个供人们使用的通用接口,这样我就可以更改它指向的表结构,而无需任何人注意到或将来不必更改其端的代码。
当用户必须插入许多记录时就会出现问题。通常,他们能够执行 INSERT 语句,一次插入许多记录,但使用此接口,他们被迫循环遍历每条记录,单独插入它。速度不是这里最大的因素,可访问性才是。
我考虑过使用视图,但我不确定这效果如何。我对他们还不够熟悉,无法确定。另外,来自其他服务器的查询可能正在访问该接口,并且我认为视图不允许您从另一台服务器插入。
你建议我做什么?
I have set up a stored procedure for inserting a single record into a table. The reason for this is to create a general interface for people to use so I can change the table structure that it points to without anyone noticing or having to change code on their end in the future.
The problem occurs when the user has to insert many records. Normally they would be able to do an INSERT statement which inserts many records at once but with this interface they are forced to loop through each record, inserting it individually. Speed is not the biggest factor here, accessibility is.
I have considered using a view but I'm not sure how well this would work. I'm simply not familiar enough with them to know for sure. Also, queries from other servers may be accessing the interface and I don't think views allow you to insert from another server.
What would you suggest I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以有 2 个存储过程。一种使用 SQL Server 的 BULK INSERT,另一种是用于插入一条记录的标准记录(您已经有了这个)。您的用户可以根据自己的需要调用其中任何一个。
有关批量插入的更多信息
http://msdn.microsoft.com/en-us/library/ms188365。 ASPX
You can have 2 stored procedures. One uses SQL Server's BULK INSERT and the other one is your standard one for inserting one record (you already have this). Your users can call either one depending on their needs.
For more info on BULK INSERT
http://msdn.microsoft.com/en-us/library/ms188365.aspx
查看 SQLBulkCopy 类。这似乎符合您的要求。
Take a look at the SQLBulkCopy class. This seems to do what you are looking for.