question

smayer avatar image
smayer asked

Updating Two Tables Through a View

What is as good work around to updating multiple tables through a view, other than following best practice / common sensibility of writing the DML against the base tables ore creating triggers? (My boss seems to think it would be desirable to update two tables though a view (I know, I know) and requested I post this question. )
sql server 2012dml
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Grant Fritchey avatar image
Grant Fritchey answered
There really isn't any way around that restriction. If you scroll down in the Books Online definition for [CREATE VIEW][1], the rules are extremely explicit. Views are just a mechanism for masking data. One of the worst things people can do is start to look on them as a mechanism for code reuse. They don't lend themselves to that. Unfortunately, T-SQL in general doesn't lend itself to code reuse. The vast majority of the time, you're much better off writing a new query or procedure rather than attempting to use a view, proc, or UDF to reuse the code. [1]: http://msdn.microsoft.com/en-us/library/ms187956.aspx
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

EXACTLY. Thanks for the confirmation.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.