Solved

From Access to SQL - Trigger

Posted on 2013-01-04
2
234 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 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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

695 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