Preserving Primary Keys in DTS

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Preserving Primary Keys in DTS

    I have a dev and production server. I want to copy the data from a table in production to DEV and preserve the primary key values. What's the best way to do this? DTS kills the keys.
    dj shane Guest

  2. Similar Questions and Discussions

    1. Autoincremented id with two primary keys
      Hi all. I have this table: CREATE TABLE sites_pages ( id int(6) NOT NULL, site_id int(4) NOT NULL, name varchar(80) NOT NULL, UNIQUE KEY...
    2. CFWDDX not preserving case on keys
      Using MX 6.1, I'm serializing a structure to Javascript and the key names are being converted to lowercase. According to the MM docs, WDDX preserves...
    3. Tablespaces and primary keys
      Implicit indexes created by a constraint do not appear to honor the default tablespace. The index gets created in the "null" tablespace. I took...
    4. Deleting Primary Keys
      Can describe how to drop a primary key from a table? Thanks, Don Bryant
    5. Primary Keys
      How is it that even though I have the column "username" in my database set as a Primary key, using my PHP script to add new users to the database...
  3. #2

    Default Re: Preserving Primary Keys in DTS

    I assume you are talking about an identity field
    disable the identity field
    then run
    SET IDENTITY_INSERT TableName ON

    run your insert

    after insert set it to off
    SET IDENTITY_INSERT TableName OFF

    Make the field and identity again


    [url]http://sqlservercode.blogspot.com/[/url]


    SQLMenace Guest

  4. #3

    Default Re: Preserving Primary Keys in DTS

    SQLMenace,

    Will this actually preserve the values I had in the table? They are out of order right now because rows were removed, etc. I'd like to preserve all that. Thanks for your help.
    dj shane Guest

  5. #4

    Default Re: Preserving Primary Keys in DTS

    Actually you don't need to disable the identity filed if you use SET
    IDENTITY_INSERT TableName ON
    Anyway the values will be preserved

    This is what you do 1:
    the field is an identity
    SET IDENTITY_INSERT TableName ON

    run your insert

    after insert set it to off
    SET IDENTITY_INSERT TableName OFF


    2
    the field is not an identity
    run your insert
    Make the field an identity

    That should do it



    SQLMenace Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139