Can I use SqlBulkCopy to insert information into a 2-table view?

I am moving on to using SqlBulkCopy to work with large inserts in some databases. This has led to big performance improvements for a single db.

However, the other target table db is a view comprising 2 tables. Using a single table code results in a "System.Data.SqlClient.SqlException: view or function" dbo.vwParameter "is not updatable because the modification affects multiple base tables." You can smooth the presentation into one table without causing many complications, although this is undesirable because it saves good disk space.

So is it possible to use SqlBulkCopy in this context, and am I just doing something wrong? Or, if not, what could be a good job that preserves the presentation for reading?

+3
source share
3 answers

It turned out that SqlBulkCopy ignored mine by default, not triggers. All I needed to do was pass the SqlBulkCopyOptions.FireTriggers to the SqlBulkCopy constructor.

+3
source

Have you looked at the documentation about updating data in views? There are two possible solutions, and the first one is probably the one you want.

0
source

You can use the view with SqlBulkCopy.
But I think your problem is that the view you have is not updatable.
There are certain requirements that must be consistent with the opinion, which can be updated.
You can find more information here http://msdn.microsoft.com/en-us/library/ms187956.aspx
Find the "Updated Views" section.

I would suggest that you fill out each of these two tables directly, if possible, if possible?

0
source

All Articles