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 |
raxbat
Yak Posting Veteran
52 Posts |
Posted - 2007-12-14 : 09:17:12
|
Hello all!I want optimize my table!currently situation(fragment form table):datetime Value14/12/2007 09:01:01 114/12/2007 09:01:02 114/12/2007 09:01:03 114/12/2007 09:01:04 214/12/2007 09:01:05 214/12/2007 09:01:06 214/12/2007 09:01:07 214/12/2007 09:01:08 214/12/2007 09:01:09 2I want trigger to control the data, for example: do not insert a row, if the Value is the same as previous, but time is different!Thanx for any help |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-14 : 11:43:07
|
You can do this by means of an INSTEAD OF INSERT triggersomething like:-CREATE TRIGGER T_{tablename} ON {tablename}INSTEAD OF INSERT ASBEGINIF NOT EXISTS (SELECT * FROM {table} tINNER JOIN INSERTED iON i.Value=t.Value)BEGININSERT INTO table(datetime,Value)SELECT datetime,ValueFROM insertedEND |
 |
|
raxbat
Yak Posting Veteran
52 Posts |
Posted - 2007-12-14 : 14:29:18
|
Thanx. But I have an error when checking syntax:Incorect syntax near END |
 |
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-12-14 : 14:32:35
|
You have 2 BEGIN's, need two END's |
 |
|
|
|
|