Solved

Trigger update on 1st record entered

Posted on 2012-04-08
2
202 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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

790 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