I need a view to insert records to a table

  • I've gotta set up a view that either drops; re-creates and inserts records into a physical or temp table. Then I need to create a second view that queries from the table created above and other joined tables.

    View # 2 will be provide to a Crystal end user to connect for their own reporting.

    I'm having issues trying to create view # 1 may be b/c it's trying to insert records into a table. Can this be done?

    Thx,

    John

  • A view that modifies data?

    Do you mean a script that modifies data, or do you mean a view that you can run a script against to modify data?

    A view is just a stored Select statement.

    If you want to update data in a table, via a view, it has to follow specific rules. These are documented here: http://msdn.microsoft.com/en-us/library/ms187956.aspx

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • you can create an INSTEAD OF trigger on a view, and have that trigger do the DML to the desired underlying tables.

    your code will then try to insert/update/delete fromt he view isntead of the real, underlying tables, is that what you wnat?

    what would be differnet about the second view that makes it unique fromt eh first view? why do you think you need two seperate views?

    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 3 posts - 1 through 3 (of 3 total)

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