SQL Insert Trigger

  • zayidka (5/1/2011)


    Did not get to the SAT yet, but

    I have changed

    IF (SELECT Due_Amount

    FROM dbo. Student_Bill_Account

    WHERE Due Amount) > 0

    So if some random row in the table with a due amount > 0, this particular insert will fail? Even if this particular insert had a Due_Amount = 0?

    ELSE

    IF EXISTS (SELECT coursed

    FROM dbo.registration

    WHERE dbo.registration .SID = INSERTED.SID)

    That's going to give you a syntax error since you reference the table inserted but never define it. Read up on Joins

    I strongly suggest you read over your course material again if it talks about triggers, if not read up on triggers in Books Online (SQL online help)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • SELECT COUNT( courseId)

    FROM dbo.registration

    WHERE SID = Inserted.SID AND course_name = inserted.course_name ) = 0

    BEGIN

    INSERT INTO dbo.Registration (SemesterID, CourseID, SID,Instructor)

    VALUES (,’ , ;, ) (How can I provide these values will % work? Should I enter Column Name?

    Thanks for your Time,I realy appreciate the Help.

  • zayidka (5/1/2011)


    SELECT COUNT( courseId)

    FROM dbo.registration

    WHERE SID = Inserted.SID AND course_name = inserted.course_name ) = 0

    That's going to give you a syntax error since you reference the table inserted but never define it. Please go and read up on Joins.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • When I asked what do you mean by 2,400 Tests?

    You said:

    It is Basically a SAT Test Name

    Please see it here http://en.wikipedia.org/wiki/SAT

    The site that you refered me to describes the SAT Test.

    If you are referring to the SAT Exam it is only one test. What do you mean by 2,400 Tests? What kind of test are you referring too?

    You mentioned that you are stack, I'm stuck as what you are trying to say...

    Help me out a little bit but I do not follow you.

    Perhaps there may be a slight language barrier.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Welsh,

    Thank you very much for your help.

    To safe sometime lets assume SAT requirement is the student to score at least 50%.

    I don’t know if I want talk about letter missing here and there in somebody’s writing.

    Because there are just too many, For example start by checking yours first.

    You said “If you are referring to the SAT Exam it is only one test. What do yo mean by 2,400 Tests? What kind of test are you referring too?”

    Can I say what do you mean, “What do yo mean by 2,400 Tests?” it is what do you mean, not “yo”

    Or “What kind of test are you referring too?” because you should have said (To not “too”)

    You kind but take the pickiness out of it.

    Thank you again.

  • :hehe:Yo! Who has to take 2,400 test to get into college? What kind of test are you refereing to? I was just asking you to clarify your question? What do you mean by 2,400 Test?

    You can't even regergetate your homework assignment into English and you are asking for people to help you cheat.

    You may want to consider writing some code as opposed being the spell check police. Gail went out of his way to help you. You need to try; make an attempt. Go for it!

    Good luck with your home work assignment.

    Since you have such a command of the English language, you might want to consider changing your major to English.

    You could get a job as a Work Study English Tutor to help pay for you tuition.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • You are stupid idiot who has too much time to waste.

  • You got an A+ on your project.:cool:

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Thank You!

  • zayidka (5/1/2011)


    Can I say what do you mean, “What do yo mean by 2,400 Tests?” it is what do you mean, not “yo”

    Or “What kind of test are you referring too?” because you should have said (To not “too”)

    You kind but take the pickiness out of it.

    zayidka (5/1/2011)


    You are stupid idiot who has too much time to waste.

    What???

    We're trying to help here. Corgi is asking for clarification on the requirements because he doesn't fully understand. Neither do I for that matter. Now if you don't want any more help, that's fine. If you do, insulting the people trying to help is not going to get you anywhere.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I removed the comment for I did not want to insult anyone.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Gail, You helped me so much already and I do really appreciate it.

    I don’t know if you have read everything between my friend and I, if you did do you really think asking someone why they write an A instead of U in simple word that 3 year old can understand is necessary?

    I thank you for your time.

  • zayidka (5/1/2011)


    if you did do you really think asking someone why they write an A instead of U in simple word that 3 year old can understand is necessary?

    No one asked you anything like that. You're the one who suddenly started picking on Corgi's writing. Unnecessary and uncalled for. We're trying to understand your requirements and asking questions to work things out. Remember, we can't see your computer, your papers or anything you've done, and your explanations have been quite vague.

    Now, if you want help, let's go back several steps.

    Explain your requirements in detail. Not vague generalities.

    Post the code you've tried and state what doesn't work

    Read up (in your coursework) or ask your tutors about triggers and joins. It's pretty obvious that you're not clear on those concepts.

    And an apology to Corgi would be nice.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I don’t think he is upset neither m’I, we are having good time.

    Here is what started our nice conversation

    Corgi said,

    “You mentioned that you are stack, I'm stuck as what you are trying to say...”

    What do you think?

  • zayidka (5/1/2011)


    Corgi said,

    “You mentioned that you are stack, I'm stuck as what you are trying to say...”

    What do you think?

    I think that he, like me, is having difficulty understanding the requirements that you've given and would like you to explain them more. We'd really prefer if you would lay out your requirements in a logical fashion, don't assume that something is obvious (I for one have no idea what you mean by 'a 2400 Tests' nor what it means for your requirements). You're jumping around from requirement to requirement, not explaining any in sufficient detail to get useful help.

    You are reading insults where there are none, reading insults into what are just requests for clarification.

    Step 1. Got and read up on triggers, joins and basic SQL queries. Or ask your tutor/lecturer to go over it with you.

    Step 2. Take each individual requirement and have a go at the code. Unless you were specifically told to use triggers, they may not be the best place. Personally these rules are ones I would check before trying an insert/update, not in a trigger

    Step 3. For any requirement that you're stuck on, post the code, the detailed requirement (not vague description) and exactly what problem you are having.

    Oh, and I think you still owe Corgi an apology.

    btw, all the people here are volunteers with their own jobs. We're not paid to post or help out.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 16 through 30 (of 34 total)

You must be logged in to reply to this topic. Login to reply