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.Unlike stored procedures (which also support parameters), these parameterized functions can be updateable, as you'll see later in this chapter.

sql view not updating-18

To avoid defining the view in two places, I want to use SELECT * to create the proxy view.

I've searched for reasons not to do this and didn't find any.

So, a view that returns the top 100% by sales would essentially be a sorted view.

The triggers in views are covered later in this chapter.

It's a bad practice for a multitude of reasons, and going out of your way to make exceptions is inconsistent and can often encourage the wrong thing to junior developers.

Views are saved SELECT statements that allow you to operate on the results that are returned from them.Anyone have an opinion on using SELECT * for a view definition?USE tempdb; GO -- simple table with two int columns CREATE TABLE dbo.x(a INT, b INT); GO INSERT dbo.x(a,b) VALUES(1,2); GO -- simple view using SELECT * CREATE VIEW dbo.v_x AS SELECT * FROM dbo.x; GO -- view will not be updated to see these changes: EXEC sys.sp_rename N'dbo.x.b', N'c', N'COLUMN'; ALTER TABLE dbo.x ADD b DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP; GO -- view shows wrong data SELECT * FROM dbo.x; SELECT * FROM dbo.v_x; GO in a view?As far as the user is concerned, the view looks just like a table.The following Transact-SQL statement selects all the data for the view shown in Listing 9.1, sorting the result set on the Company Name column: statement wouldn't have to change. Company Name Views are created inside individual databases, however, views can reference tables and views in other databases or even on other servers (if the view is defined using distributed queries).They can be used to provide row- or column-level access to data, to wrap up complex joins, to perform complex aggregate queries, and to otherwise customize the display of data. In this chapter, learn how to define, create, and modify views, and how to perform index analysis and optimize performance in SQL Server. The biggest problem is that just when you get used to accepting a limitation, Microsoft comes up with an amazing, new feature that overcomes it!