Updating multiple tables sql server
It's great to get the extra features, but it makes it harder to nail down exactly what you can and cannot do with views.
Views have never in the past been able to contain parameters; however, as shown later in the chapter, user-defined functions can now be used like views, effectively allowing you to create parameterized views that return different results depending on the parameter values that get passed in each time the function is run.
To return the top 10 customers or the top 10% of customers, based on sales over the past year, SQL Server needs to sort customers by sales.
So, a view that returns the top 100% by sales would essentially be a sorted view.
Unlike stored procedures (which also support parameters), these parameterized functions can be updateable, as you'll see later in this chapter.
The SQL-92 standard also mandates that views cannot be sorted with an values with a view; to support that, it also supports sorting.
In the case where the application server and database server are on different hosts, the round-trip will involve network latency as well.
This can be implemented using the Once the view is created, its definition will be unreadable, as shown in Figure 9.2.
Therefore, make sure that you save your view definition in a script file in case you ever need to modify it.
A requirement arises in many systems to update multiple SQL database rows.
For small numbers of rows requiring updates, it can be adequate to use an UPDATE statement for each row that requires an update.