Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

From Access to SQL - Trigger

Posted on 2013-01-04
2
Medium Priority
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1500 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

636 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