Solved

SQL Server Stored Procedure to update records

Posted on 2013-06-27
2
346 Views
Last Modified: 2013-07-02
I have a view built that combines data for 2 tables. Its filtered to return just the records I need. I want to update data in each of the two tables (just updating two fields in each table, i an int and a varchar field). At the same time I want to insert data into a 3rd table not in the view. So for each record in the dataset, update 2 fields in each table and then insert a record into another table for each record updated. That last part of inserting I'd like to call a stored procedure that is already built. Is this possible? The goal is to update the records in bulk and capture that it was done and by who in another table. I hope this makes sense. I'm using SQL Server 2008. Thanks.
0
Comment
Question by:dodgerfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 total points
ID: 39282568
I think it may be possible to do all that you want by using an INSTEAD OF INSERT trigger on the View.  (Note this trigger should be built on the View and not on the underlying tables.)

Here is an article to get you familiar with this concept:
http://blog.sqlauthority.com/2013/01/24/sql-server-how-to-use-instead-of-trigger-guest-post-by-vikas-munjal-koenig-solutions/
0
 
LVL 25

Expert Comment

by:jogos
ID: 39282912
The instead of trigger indeed. A little warning for triggers: make shure it works when yiu insert or update multiple rows in lne statement.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question