ALTER VIEW in SQL Server
The ALTER VIEW command allows us to modify the existing data.
ALTER VIEW [schema_name.]view_name AS
[ WITH { ENCRYPTION | SCHEMABINDING | VIEW_METADATA }
SELECT expressions
FROM tables
WHERE conditions;
Consider the CUSTOMERS table having the following records:
+----+----------+-----+-----------+----------+
| 1 | Ranith | 32 | Ahmedabad | 2000.00 |
| 2 | Krupa | 25 | Delhi | 1500.00 |
| 3 | kaulik | 23 | Kota | 2000.00 |
| 4 | Chaitan | 25 | Mumbai | 6500.00 |
| 5 | Munny | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+
For the following example,if we want to add title to each column then it uses ALTER VIEW syntax as follows:
CREATE OR REPLACE VIEW contacts AS
SELECT
ID, NAME, AGE, ADDRESS, SALARY
FROM
employees;
This would produce the following result:
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ranith | 32 | Ahmedabad | 2000.00 |
| 2 | Krupa | 25 | Delhi | 1500.00 |
| 3 | kaulik | 23 | Kota | 2000.00 |
| 4 | Chaitan | 25 | Mumbai | 6500.00 |
| 5 | Munny | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+
SQL Server Connection String Formats
posted on 2019-08-27 05:53:53 - SQL Server Tutorials