How to insert data in derived columns SQL

543 views Asked by At

I have a view which contains a derived column, and I need to create a stored procedure which make an insert into the view

I've tried

CREATE PROCEDURE INSERTInVIEW
(
    @ID DECIMAL(10,2),
    @Name ....,
    @Address....,
    @Phone
)
AS
BEGIN
    INSERT INTO MyView (ID, Name, Address, Phone)
    VALUES (@ID, @Name, @Address, @Phone)
END

where the Address is a computed field in the view. I getting the error that the insert failed because it contains derived or computed field. Which should be the best way to do this insert?

1

There are 1 answers

0
Russell Fox On

If your view is based on multiple tables it's likely not updateable. Try checking the information_schema tables:

SELECT IS_UPDATEABLE
FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLENAME = 'YourTableName';