Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Trigger problem!

Author  Topic 

romzilla
Starting Member

6 Posts

Posted - 2007-11-15 : 02:55:00
Hi
I am new to SQL server (MS SQL Server 2005 Standart Edition) so maybe someone could help me with trigger problem. I have just gone through some material about triggers, but still some issues should be cleared. Let me try do describe the situation
I have table profile, colums f_condition(integer), f_glabat_lidz(integer) and f_lietas_dat(date) in it. f_lietas_dat is filled by user in application but field f_glabat_lidz needs to be calculated automatically(
f_glabat_lidz = year of f_lietas_dat + 5 if f_condition = 5
f_glabat_lidz = year of f_lietas_dat + 10 if f_condition = 10
for example). This should be done on every insert or update. I created this example trigger, this is the idea, but it does not work. Maybe someone could help to solve this problem? It is very urgent! Thank You for help!

CREATE TRIGGER profile_trg
ON profile
FOR INSERT, UPDATE
AS
BEGIN
INSERT profile (f_glabat_lidz)
SELECT YEAR(f_lietas_dat)+1
FROM inserted
END

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2007-11-15 : 03:23:37
duplicate
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92712

Em
Go to Top of Page
   

- Advertisement -