Will a sqlserver view always be up to date or can there be a delay on it?
That depends on the transaction isolation level the view runs at. By default, views run at READ COMMITTED
. The view will return only committed data. As long as your view consists of only one SQL statement, and doesn't call user defined functions or extended procedures, it will be consistent.
But views can also run at a more risky isolation level. For example, this view specifies nolock
so it runs at READ UNCOMMITTED
:
create view dbo.MyView
as select * from dbo.MyTable with (nolock)
This view can return values that are part of a transaction that will be rolled back (dirty read.) This transaction isolation level trades consistency for performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With