SQL SERVER

Updatable views in SQL Server

Updatable views in SQL Server
Avatar of shohal
Written by shohal

Updatable views in SQL Server

As we know view is a virtual table .It’s nothing more then to saved only sql query. View can update on single table.

Example :

CREATE TABLE tblEmp
(
Id int Primary Key,
Name nvarchar(30),
Salary int,
Gender nvarchar(10),
DepartmentId int
)

Insert into tblEmp values (1,’J’, 5000, ‘Male’, 3)
Insert into tblEmp values (2,’M’, 3400, ‘Male’, 2)
Insert into tblEmp values (3,’P’, 6000, ‘Female’, 1)
Insert into tblEmp values (4,’T’, 4800, ‘Male’, 4)
Insert into tblEmp values (5,’S’, 3200, ‘Female’, 1)
Insert into tblEmp values (6,’B’, 4800, ‘Male’, 3)

Create view vWEmpDataExceptSalary
as
Select Id, Name, Gender, DepartmentId
from tblEmp

Select * from vWEmpDataExceptSalary

Update vWEmpDataExceptSalary 
Set Name = ‘Mikey’ Where Id = 2

That’s it if we update tow or more table it’s going wrong because A VIEW does not require any storage in a database because it does not exist physically.

Note: SQL Develop Suggest to not update on View.

🚀
Updatable views in SQL Server | TechTweet

If you’d like me to proceed with any of these, please just let me know from the site techtweet.xyz! Also if you need to learn something new than subscribe YouTube : ASP.NET With SQL SERVER


About the author

Avatar of shohal

shohal

I have profession and personal attachment with custom ERP Software development, Business Analysis, Project Management and Implementation almost (36) ,also Oracle Apex is my all-time favorite platform to developed the software. Moreover i have some website development experience with WordPress. For hand on networking experience DevOps and CCNA, it create me a full package. Here are some core programming language with networking course i have been worked: Oracle SQL ,PL/SQL,Oracle 19c Database , Oracle Apex 20.1,WordPress,Asp.Net ,MS SQL ,CCNA ,Dev Ops, SAP SD

Leave a Comment