To increase value from Engg0 to Engg1, Engg2, and so On!!!

  • Hello,

    When I create table as per code data is inserted in first successfully as ENG_REF value Engg0000000000 but when i insert in second row it showing an error message "Can not Insert Duplicate Key"

    Any idea how to fix it.

  • Gopal Singh (5/26/2011)


    Hello,

    When I create table as per code data is inserted in first successfully as ENG_REF value Engg0000000000 but when i insert in second row it showing an error message "Can not Insert Duplicate Key"

    Any idea how to fix it.

    my fault; the formula for the calculated column should have used the RIGHT function, not the LEFT.

    i edited the psot above, so you can grab it again.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Hello David,

    Using your code My Problem was sloved, Thanks for It.

    I have another issues. I have one parent table that is Eng_Details and one child table that is Eng_Edu_Details.

    My Question is when I enter information in End_Edu_Details, Date are changes as last time modified it in Eng_Edu_Details, but not changes the dates in Eng_Details, I have seprate trigger on both table when any record insert in child table date shpuld change to current date when record are insert or modified.

    Primary key of Parent table is foreign key in child table.

    Can you give me how to do it like by triggers????

  • Post your trigger definition on End_Edu_Details and we can help you modify it to also update the date on Eng_Details.

    ______________________________________________________________________________
    How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.

  • Hello,

    I need to create trigger which allow to insert primary key in main automatically when inserted to it and then automatically inserted in child table

    create trigger trg_Eng_Edu_Details on dbo.Eng_Edu_Details

    declare @dt varchar

    set @dt=getDate()

    for insert as update t set t.curr_date=(CONVERT(VarChar(50), GETDATE(), 101)) from Eng_Edu_Details t

    inner join inserted i on i.Eng_Id=t.Eng_Id

    go

Viewing 5 posts - 16 through 19 (of 19 total)

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