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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:27:36+00:00 2026-05-20T07:27:36+00:00

Dear i already create one table for employee information with ASP.net interface now i

  • 0

Dear
i already create one table for employee information with ASP.net interface
now i show add one operation in my table as below,

i have four columns( WorkDatey,WorkDatem,WorkDated,absentday) all the columns from integer type in table name employee.
now i should add new column (realworkdays) and the result here should be automatic save after entering previous data as example:

    WorkDatey= 2011 ,
    WorkDatem= 2  ,
    WorkDated=14 ,
    absentday=6

the operation should be : (2011*365)+(2*30)+(14)-(6) and result will store in column (realworkdays).

i already try it as trigger but i have some thing wrong:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER daysResult
   ON  [dbo].[employee]
   AFTER insert
As
DECLARE @realworkdays int

BEGIN
    SET NOCOUNT ON;


select WorkDatey,WorkDatem,WorkDated,absent from [dbo].[employee]
@realworkdays= (workdatey*350)+(workdatem*29)+(workdated)-(absent)

insert into [dbo].[employee] (totaldays)values (@realworkdays)

END
GO
  • 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-20T07:27:37+00:00Added an answer on May 20, 2026 at 7:27 am

    You are supposed to update the inserted records, not insert new ones.

    So, it should be the UPDATE statement, and you can do both the calculations and the updates in one go.

    CREATE TRIGGER daysResult
    ON [dbo].[employee]
    AFTER insert
    AS
    BEGIN
      UPDATE employee
      SET realworkdays = (inserted.workdatey*350)+(inserted.workdatem*29)+
                         (inserted.workdated)-(inserted.absent)
      FROM inserted
      WHERE employee.ID = inserted.ID
    END
    

    Still it would be better to use a computed column, as @The Scrum Meister has suggested.

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

Sidebar

Related Questions

Dear All, I'm using dojo.declare to create classes in JavaScript. In one of the
Dear all from the below mentioned table im picking imgurl with this query but
dear all i want to know how to submit asp.net form data using jquery
Dear all how could im set response status in Asp.net Web service method ?
Dear all, the question like this one has been already asked , but among
Dear Stackoverflowers, I am trying to build a simple web application in ASP.NET where
Dear Stacktoverflow, can you show me an example of how to use a QScrollBar?
Dear all,Now i have this question in my java program,I think it should be
Dear all devexpress winform gurus:) My way is simple. First, i create a bindinglist:
dear all..i have a table it looks like: Name version DDX 01 DTX 05

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.