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 8393033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:40:53+00:00 2026-06-09T19:40:53+00:00

I have a database table as follows: create table Table1( Date varchar(10), Batch_Name varchar(50),

  • 0

I have a database table as follows:

create table Table1(
Date varchar(10),
Batch_Name varchar(50),
Hall_Name varchar(50),
Lecturer_Name varchar(100))

I want to create a trigger for this table, which will restrict inserting the same Batch Name, Hall Name, OR Lecturer name on a particular day.
For example: if the user inserted,

**Record 1 :** 2012/08/15 - Batch 1 - Hall 1 - Lecturer 1
**Record 2 :** 2012/08/15 - Batch 2 - Hall 2 - Lecturer 2

to the table, it should be correct. But if the user tried to insert as

Record 1 : 2012/08/15 – Batch 1 – Hall 1 – Lecturer 1

**Record 2 :** 2012/08/15 - Batch 1 - Hall 1 - Lecturer 2 **OR**
**Record 2 :** 2012/08/15 - Batch 1 - Hall 2 - Lecturer 1 **OR** 
**Record 2 :** 2012/08/15 - Batch 2 - Hall 1 - Lecturer 1 

it should provide an error.

I am using this table to create a time table for a particular system. What I am trying to achieve by this trigger is that I want to provide an error if the user tries assign the same hall, lecturer or the Batch on the same day on different records, which obviously is an over allocation.
I am quite a newbie when it comes to triggers, so I would really appreciate if someone can provide me a solution for this scenario! and I am using MS SQL Server 2008 as the DBMS.
Thanks in advance!

  • 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-06-09T19:40:55+00:00Added an answer on June 9, 2026 at 7:40 pm

    i think this is not necessarily a trigger

    this sounds like a set of 3 unique indexes.

    create a unique index on the pairs:

    day, lecturer
    day, batch
    day, hall
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have database table like this +-------+--------------+----------+ | id | ip | date |
I have a database table named Categories . I want to create a form
In my database, assume we have a table defined as follows: CREATE TABLE [Chemical](
I have an sqlite database structured as follows: CREATE TABLE IF NOT EXISTS Patient
I have a table in a postgresql-9.1.x database which is defined as follows: #
I have a database table with some rows that I want to fetch using
I have a database table containing dates (`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00').
I have a database table using an enum. This is already working with hibernate
I have database relation as follows between question table and Hardware detail table .
I have a SQL Server 2008 database that has a Trigger. This trigger is

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.