Solved

From Access to SQL - Trigger

Posted on 2013-01-04
2
229 Views
Last Modified: 2013-01-07
I have what was a simple Update Query in Access to what i am thinking should be a After update\insert Trigger in SQL.
Access Query
UPDATE SEGMENT SET SEGMENT.LeftOdd = 1
WHERE ([L_F_add] mod 2) = 1 OR  ([L_F_add] = 0 AND [R_F_add] > 0 AND ([R_F_add] mod 2) = 0);

Open in new window


Im not sure how to determine if the L_T_ADD value = odd number or the L_F_ADD value = oddnumber statement should work.
Suggestions
It looks like this "x % 2" would be the way?
Thanks
0
Comment
Question by:PtboGiser
2 Comments
 

Author Comment

by:PtboGiser
ID: 38745101
Then if L_F_ADD or L_R_ADD is odd then i need to set the LEFTODD column to a value of "1"
0
 
LVL 12

Accepted Solution

by:
Jared_S earned 500 total points
ID: 38745315
It looks like you've already got it.

CREATE TRIGGER myTrigger
ON SEGMENT
AFTER INSERT, UPDATE
AS

UPDATE SEGMENT
SET SEGMENT.LeftOdd = 1
WHERE (([L_F_add] % 2) = 1
OR  
([L_F_add] = 0 AND [R_F_add] > 0 AND ([R_F_add]%2) = 0));
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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…
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.
Viewers will learn how the fundamental information of how to create a table.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now