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.
Author |
Topic |
d247
Starting Member
6 Posts |
Posted - 2014-04-06 : 19:10:15
|
Hi everyone,I have the following working correctly as a trigger, however, I want to change one of the values (2016) to calculate the current year's value.. so in 2017, it would put 2017.Can anyone tell me the SQL command to do so?CREATE TRIGGER TRG_NEW_EQUIPMENTON ATHLETE AFTER INSERTASBEGININSERT INTO Equipment (Equipment_ID, Equipment_Model, Equipment_Year, Equipment_Brand, Equipment_Color, Equipment_Condition_Rating)VALUES ('150','Big Spin','2016','K2','Blue','5')END;GO |
|
d247
Starting Member
6 Posts |
Posted - 2014-04-06 : 19:12:15
|
In SQL Server |
|
|
d247
Starting Member
6 Posts |
Posted - 2014-04-06 : 19:18:12
|
Nevermind - I got it!!!CREATE TRIGGER TRG_NEW_EQUIPMENTON ATHLETE AFTER INSERTASBEGININSERT INTO Equipment (Equipment_ID, Equipment_Model, Equipment_Year, Equipment_Brand, Equipment_Color, Equipment_Condition_Rating)VALUES ('150','Big Spin',(Year(GETDATE())),'K2','Blue','5')END;GO |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2014-04-07 : 09:10:21
|
You can also use datepart(year,GETDATE())MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|