Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:38:09+00:00 2026-05-31T16:38:09+00:00

I am studying the trigger and I got a question. I am creating a

  • 0

I am studying the trigger and I got a question.

I am creating a trigger to change the time complex.

In the data table weeklymeeting

|section_id| meeting type| days| timestart|timeend|class_id|
| 13       | Lecture     |   5 | 01:00:00 |02:00:00|12     |

timestart and timeend are of datatype TIME

I am creating the trigger that checking the time complex

for example

if user uses query like

INSERT INTO DBO.WeeklyMeetings VALUES (35, 1,1 ,'11:40:00','11:42:00', 42)

it should insert the data

however

INSERT INTO CSE132B.DBO.WeeklyMeetings VALUES (35, 1, 1, '12:30:00','01:30:00', 42)

then it must return error message because it is time complex

Therefore I created a trigger to check the time complex..but such as

ALTER TRIGGER [dbo].[check_section_time_complex] ON [dbo].[WeeklyMeetings]
FOR INSERT AS
IF EXISTS(select * from inserted as i INNER JOIN dbo.WeeklyMeetings as m  ON (i.timestart BETWEEN m.timestart and m.timeend)  
OR( i.timeend BETWEEN m.timestart and m.timeend ))
begin
 RAISERROR ('Can not update data because  section time is complexing with other section!!', 16,1);
rollback tran
end

however, it is not really working…i am not really sure that reason….

does anyone knows problems in this trigger ?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:38:10+00:00Added an answer on May 31, 2026 at 4:38 pm

    If by “it’s not really working” you mean that it’s allowing conflicting data to be inserted and then raising an error, this is because you’ve specified a FOR INSERT trigger which means that it’s happening after the data is inserted.

    If you want to prevent the data being inserted you’ll need to use an INSTEAD OF trigger which happens before insert and within that do the insert yourself if it is valid.

    See http://msdn.microsoft.com/en-us/library/ms189799.aspx for the trigger definition.

    If the error is something else please describe it more fully.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am studying triggers and constraints. And I got a question to use trigger
Studying MS Exam 70-536 .Net Foundation I've got to Chapter 11 Application Security and
I've been studying the Google authentication API (AuthSub)... My question is, how do I
I'm studying Javascript cookie. Basically what I want is when the first time user
While studying for the SCJP 6 exam, I ran into this question in a
I am studying an application to trigger a PHP script based on new IMAP
I am new to studying jquery.ajax. I want to paste some data from a.php
while studying some security things, there was a question that one can guess the
I have been studying Ruby for the past few days and I have noticed
While studying how to build a nested table from list elements in CSS, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.