Copying rows without losing consistency?

  • Hi

    I am building the sample data for a type of relationship table(Fact Table)  but the problem is that basically i only have to change the key value for the "State"(US) and the rest of the data can remain the same but whenever i try to do just that,the copy goes fine..but when i try to update the "State ID" attribute, it wont let me do that...it gives the error," Key Column information is insufficient or incorrect. Too many rows were affected by update"...

    this is despite the fact that the said attribute has NOT been declared a key...

    can anyone tell me why i am encountering this frustrating error and how can i get around it? i shall be REALLY thankful as it would save a lot of time inputting data...:-S

  • hi

    Are you trying to do it through the enterprise manager?. In that case the problem is that there are duplicate records.

    Hope this helps you. 


    Regards,

    Jomy John Thomas

    Your Guide to Admin and Design

  • yea,i am trying to do that thru the enterprise manager...any way around it? i dont want to waste ages entering sample data... there wud be 144 tuples AT LEAST for just one year...any suggestions?

  • Do it in QA with "update table set stateID = ...where rows = ...."







    **ASCII stupid question, get a stupid ANSI !!!**

  • yea,i did consider it but the problem is that the update would only replace the IDs for the original data while i need to copy it,changing only the TimeID and StateID..???

  • Hi

    try this .

    Select *,Identity(1,1)NewID Into #Temp from YourTable .

    Update YourTable Set TimeID=NewTimeId, StateID=NewStateID where NewID =YourCondition

    Delete from YourTable

    Insert Into YourTable

    Select * From #Temp.

    Hope this works.

    If it doesn't can you post your table structure?

     

     


    Regards,

    Jomy John Thomas

    Your Guide to Admin and Design

  • Thanx guyz!the problem has been solved...

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=169&messageid=199194&post=true

    take care...thanx once again...

Viewing 7 posts - 1 through 6 (of 6 total)

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