SQL Server Performance

Insert Problem

Discussion in 'SQL Server 2005 General DBA Questions' started by -RJ, Nov 7, 2005.

  1. -RJ Member

    I have a record that was somehow deleted out of the database. I am not sure how it happened, and that is another story... Anyway, from a previous backup, I have the information for that record. But, since I am using the primary key field, I cannot just re-insert that row.

    How can I restore just a single row? I suppose I have to remove the constraint, then replace the constraint? Any suggestions on how do do this or anything I should be concerned about?
  2. DBA_Newbie New Member

    Am confused ! The primary key that you are using is it an identity element ?
    If yes, then it shouldnt matter. Because the row if it was deleted, then the identity element would still be unique.

    If not, then update the remaining columns for that row.

    More over if you insert the record by removing the constraint and then try adding it, it wont allow to add the primary key constraint if the PK is not unique.

    Hope this helps.

  3. -RJ Member

    Yes, it's an identity element.

    It tells me the cell that contains the primary key cannot be modified.
  4. -RJ Member

    I was also wondering if there might be a "with nocheck" option that I might be able to use?
  5. -RJ Member

  6. mmarovic Active Member

    Use:<pre id="code"><font face="courier" size="2" id="code">set identity_insert &lt;table name&gt; on<br />insert into &lt;table name&gt; (&lt;all columns&gt<img src='/community/emoticons/emotion-5.gif' alt=';)' /> values(...)<br />set identity_insert &lt;table name&gt; off</font id="code"></pre id="code">

Share This Page