Solved

Trigger update on 1st record entered

Posted on 2012-04-08
2
203 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

749 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