Solved

Trigger update on 1st record entered

Posted on 2012-04-08
2
205 Views
Last Modified: 2012-06-27
Hi,

I need to update another table only when the first record is added.
How would I do this?

Thanks
0
Comment
Question by:Sheritlw
[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 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 37822515
did you mean of the first record in that table ?
then try this sytas. change the query for update as per your requirmenr

CREATE TRIGGER invUpdate ON [Table_Name]
FOR INSERT
AS
Declare @cnt int



IF Not exists (SELECT * FROM Table_Name)
BEGIN
  Update Another_Table_Name
  set value = value_here_from_inserted_table
  where id  = value_here_from_inserted_table
END


refer
http://www.codeproject.com/Articles/7304/Brief-about-Triggers-in-SQL-Server-2000
0
 

Author Closing Comment

by:Sheritlw
ID: 37846450
Thank you
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

729 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