T-SQL Tutorial

T-SQL Modify Data From View


Modify Data From View Example

CREATE VIEW CountriesView
  AS
SELECT * FROM countries ;

INSERT INTO CountriesView(Country_Id, Country_Code, Country_Name)
  VALUES (8, 'ESP', 'SPAIN');

Country_IdCountry_CodeCountry_Name
1USUNITED STATES
2ENGENGLAND
3FRAFRANCE
4DEUGERMANY
5CANCANADA
6AUSAUSTRALIA
7JPNJAPAN
8ESPSPAIN

UPDATE CountriesView
   SET Country_Code='ITA', Country_Name='ITALY'
 WHERE Country_Id=8;

DELETE FROM CountriesView WHERE Country_Id=8;