SQL server 2005 Insert into table select * from table

  • my procedure runs successfully except for first insert query does not insert rows into the table but auto increments id. but Other querys execute successfully. I am attaching procedure below. Please guide where I am wrong :

    --remove_preorder_details 140

    /******* TARUN *********/

    ALTER procedure [dbo].[remove_preorder_details]

    @product_id int,

    @userid int

    as

    insert into vss_user

    select first_name,last_name,email,company_name,job_title,phone,fax,business_id,ref_id,register_date,login_status,first_login_flag,

    active,user_type,parent_id,subscription_days,

    (select Subscription from vss_configuration)subscription_end_date,google,delUserSet,order_id

    from vss_user_backup

    where userid=@userid

    declare @vss_user_userid int

    set @vss_user_userid=(select max(userid) from vss_user)

    update vss_multi_user_options_admin

    set userid=@vss_user_userid

    where userid=@userid

    insert into vss_users_login

    select @vss_user_userid,email,password,'unchanged'

    from vss_temp_pre_order_detail join vss_user_backup on vss_user_backup.userid=vss_temp_pre_order_detail.user_id

    where user_id=@userid

    update vss_users_login

    set userid=@vss_user_userid

    where userid=@userid

    delete from vss_temp_pre_order_detail where user_id=@userid

  • vikramp 2790 (9/26/2011)


    my procedure runs successfully except for first insert query does not insert rows into the table but auto increments id. but Other querys execute successfully. I am attaching procedure below. Please guide where I am wrong :

    if there is a trigger on the table, the trigger may be written wrong, or someone coded for an explicit exception, and is rolling back the transaction; that is exactly the behavior i'd expect to see: identity() increments , but the data is missing because the rollback occurred.

    look for a trigger on that table and let us know.

    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!

  • No, there is no trigger fired on that table. Acctually, it runs for some @userid perfectly. but not for some @userid.

Viewing 3 posts - 1 through 3 (of 3 total)

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