Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys
i have 2 table that i linked using one view.

first table: customer_data

columns: 1- customer_id -> primary key
columns: 2- customer_name -> nvarchar(50)

second table: payment

columns: 1- id -> primary key
columns: 2- customer_id -> int not null
columns: 3- paymnet_value -> money
columns: 4- payment_date -> date

and the view is:
columns: 1- customer_name / table {customer_data
columns: 2- payment_value / table {paymnet}
columns: 3- payment_date / table {paymnet}

this query that i used:

SQL
INSERT INTO [CustomerDb].[dbo].[paymnet_info]
           ([customer_name]
           ,[paymnet_value]
           ,[paymnet_date])
     VALUES ('ahmed',100,(GETDATE()))
GO


and i have got this error:

Msg 4405, Level 16, State 1, Line 4
View or function 'CustomerDb.dbo.paymnet_info' is not updatable because the modification affects multiple base tables.
Posted

1 solution

a view is a virtual table based on the result you obtained from the SQL statement
you cannot insert a new value into the view.

Pls have a look at this. sql view[^]
microsoft sql views[^]

if you want to insert into views in other way you can refer this article How to insert data using SQL Views created using multiple tables[^]
 
Share this answer
 
v2
Comments
Ahmed Emad 10-Jan-14 8:39am    
that means i can't use it to insert but use it to update or delete.
but if i want to insert data to multiple tables what should i do ??
Karthik_Mahalingam 10-Jan-14 8:44am    
you shld insert data to the tables and refresh the view..
new values will be populated automatically in the view..
simple :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900