Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 View

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-09-19 : 07:38:10
Shahbaz writes "Hi

1.Can we delete the record using view.?
2.Can we insert and update the record through view?

Thanks and Regards,
Shahbaz"

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-19 : 07:51:30
Yes it is possible, as long as the query is built only one one table and the primary key is present in the view.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-19 : 08:06:57
Check BOL for CREATE VIEW...It has a lot of information on this topic.

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-19 : 08:54:09
or create INSTEAD OF TRIGGER on the VIEW and perform the insert, update & delete in the trigger.


KH

Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-09-19 : 09:51:15
quote:
Originally posted by AskSQLTeam

Shahbaz writes "Hi

1.Can we delete the record using view.?
2.Can we insert and update the record through view?

Thanks and Regards,
Shahbaz"



Why not just try it yourself, and see what happens?





CODO ERGO SUM
Go to Top of Page

hizuka
Starting Member

7 Posts

Posted - 2006-09-21 : 12:15:26
If the view involve more than one table, using view to update data is usually fail unless you use INSTEAD OF trigger. INSTEAD OF trigger is available in SQL Server 2000 onwards.

You can also limit what's can be inserted into views with the WITH CHECK OPTION feature. With this option, the inserted or updated row must meet the WHERE criterion that used in the SELECT statement in your view

Hizuka Naomi
http://www.sqlref.com
Go to Top of Page
   

- Advertisement -