How to modify an existing T-SQL view ? To develop a SQL Server database or more generally an application, create a database and tables is mandatory. The views are also very useful because they allow you to adjust a specific number of rows and columns without changing the table structure.
How to modify a SQL Server view in T-SQL?
For example, let’s consider the Sales view created in this article. To modify the existing view, use the ALTER SQL statement. Simply change the ORDER BY clause to have the number of clients as default descending ordering.
ALTER VIEW [dbo].[SalesByMonth] AS SELECT [MonthName], [NumberMonth], SUM([NumberOfClients]) AS [NumberOfClients], SUM([Amount_ET]) AS [Amount_ET], SUM([Amount_IT]) AS [Amount_IT] FROM [dbo].[Sales] GROUP BY [MonthName], [NumberMonth] ORDER BY SUM([NumberOfClients]) DESC
This short article is on how to modify a SQL Server View? Looking for more detailed informations about the Microsoft SQL Server views, like Indexed views that are materialized? Check the online official documentation of the views for all versions, including SQL Server 2016, 2017 and 2019.