• Minnu (11/24/2015)


    hi Team,

    How to create a view with below logic,

    -- want to delete from unify table before insert.

    DELETE FROM dbo.Unify

    GO

    INSERT INTO dbo.unify (PS_code, PS_Name)

    SELECT PS_code, PS_Name FROM [dbo].[Unify_HHT]

    As others have pointed out, a view is the wrong object type for this. There's a great reminder in the name "view". That's all you get to do. The correct object type for this operation is not a view, but a stored procedure. They're for doing stuff, not just looking at stuff.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden