Inserting Data into Views

As mentioned previously, you can insert data into a view. The view has to be created in a specific way to handle data insertion. Several rules also must be followed to make these types of inserts work:

  • The SELECT statement used to make the view cannot contain any aggregate functions.

  • The SELECT statement used to make the view cannot contain GROUP BY, TOP, UNION, or DISTINCT statements.

  • Aggregate functions can be used in the FROM clause of the SELECT statement as long as the values returned by the function aren't modified.

  • The SELECT statement cannot contain any derived columns. In a view, a derived column is created by anything other than a single value from a column. This can be done by using functions, mathematical ...

Get Writing Stored Procedures for Microsoft SQL Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.