How to update a VIEW?

Posted by Vanchi050585 under Sql Server on 5/27/2011 | Points: 10 | Views : 30400 | Status : [Member] | Replies : 8
hi friends,

How to update a VIEW?


Thanks in Advance

Thanks
tvn



Responses

Posted by: Umeshdwivedi on: 5/27/2011 [Member] Starter | Points: 25

Up
0
Down
hallo
CREATE OR REPLACE VIEW vw_STUDENTS1
AS
SELECT
FIRSTNAME,
LASTNAME,
BIRTH_DTTM,
(FIRSTNAME || ' ' || LASTNAME) "FULLNAME_FL",
trunc(months_between(sysdate,BIRTH_DTTM)/12) "AGE"
FROM COURSEREGISTRATION.STUDENTS
you can update view in simple way like update query

Latest Technology Trainer
And Part time software consultant

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/30/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
You can use
ALTER VIEW <ViewName>

Begin
-------Your Updated query for the view.
End
.
Please take a look at this msdn link.
http://msdn.microsoft.com/en-us/library/ms173846(v=sql.90).aspx
Thanks,
Debata

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mshivainfo on: 5/31/2011 [Member] Starter | Points: 25

Up
0
Down
By using INSTEAD OF trigger you can update the view. Follwing link will give you for better ubderstand.

http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.sqlt.doc/sqlt328.htm


Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 5/31/2011 [Member] Starter | Points: 25

Up
0
Down
CREATE VIEW vwView1
AS
SELECT Col1, Col2, ColA, ColB, ColC
FROM Table1 AS t1 INNER JOIN Table2 AS t2 ON t2.ColB = t1.Col1
GO
SELECT *
FROM vwView1
GO
UPDATE vwView1
SET ColC = 4
WHERE ColC = 10
GO
SELECT *
FROM vwView1
GO
UPDATE vwView1
SET ColC = -Colc
WHERE ColC < 4
GO
SELECT *
FROM vwView1
GO
UPDATE vwView1
SET Col2 = Col2 / 10
GO
SELECT *
FROM vwView1


Thanks&Regards
LakshmiNarayana Nalluri.

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 5/31/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
I think this guy is asking on how to update a view not put an update statement in a view, and why would someone put an update statement in a view, it will defeat the purpose of a view.
http://www.techonthenet.com/sql/views.php

Thank you for posting at Dotnetfunda
[Administrator]

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/23/2012 [Member] Starter | Points: 25

Up
0
Down
VIEW IS AN IMAGINARY TABLE.
VIEW IS AN TEMPORARY TABLE
VIEW IT WONT OCCUPY ANY DATA
VIEW CAN INSERT , DELETE ,UPDATE STATEMENTTS

REGARDS


sriram

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ajay.Kalol on: 6/4/2012 [Member] Starter | Points: 25

Up
0
Down
ALTER VIEW VIEWNAME
AS
Your Query...
....
....
....
Go

Ajay
ajaypatelfromsanthal.blogspot.in

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajashekaranmec on: 6/27/2012 [Member] Starter | Points: 25

Up
0
Down

update viewname set columnname="YYY" where columnname="XXX"

example :
update vw_raja set FirstName="rajashekaran" where FirstName="rajan"

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response