is it possible to update a view which is created on two tables,if possible how can i do that

  • suppose i create a view on two tables emp and dept .is it possible to update a view which is created on two tables,if possible how can i do that,pls help me

  • Have a look at Books Online (BOL) - 'views, modifying data through' - this explains the various ways to do such things.

    BrainDonor.

  • Hi,

    As per Your question. i understand that u need to later the view which you created on the two tables.if yes

    Then you can use Alter [viewname] [Column....] as your select statement.

  • The usual answer: it depends on the view, and the data that is in it. when it's a simple join of multiple tables, you can often update the view directly.

    if the update you are attempting requires a key that doesn't exist (like adding a deptID and Dept_Name to a related table), you'd need a trigger on the view to put the value in the lookup table; same thing for parent child views, like invoice and Invoice Details...

    get a Dev copy of the data on your machine, and simply start testing with some basic updates. chances are, a simple update will work; inserts might require a trigger to handle FK's, it all depends ont he data in question.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply