Urgent - db insert fails after data import

  • Ok, here is my issue:

    1. I have a new blank db on my host's server (SQL 2005) Name: sparkoflife U: sparkoflife

    2. I restored a backup of a working db onto my local machine that has a different username and db name.

    3. I ran the task: Import Data and copied all the tables and data from the db on my local machine onto the blank online db.

    4. I then went into the blank db and ran this script:

    select 'exec sp_changeobjectowner ''[' + s.name + '].' + o.name + ''', ''sparkoflife'''

    from sysobjects o inner join sysusers s on o.uid = s.uid

    where s.name <> 'dbo'

    order by o.name

    5. I then created a new schema called 'sparkoflife' and modified each table changing the schema name to 'sparkoflife'.

    6. I test the database and I can modify and delete ok but Insert fails every time. I get an error message saying cannot insert the value 'NULL' into the column named 'column name' which happens to be the primary column. eg.

    INSERT INTO categories (categoryDesc, idParentCategory, categoryFeatured, categoryHTML, CategoryType,PrivateCATID, sortOrder,categoryHTMLLong,breadCrumb,breadCrumbLinked) VALUES ('Test',1,'N','',0,'',null,'','All Categories','All Categories')

    Cannot insert the value NULL into column 'idCategory', table 'sparkoflife.sparkoflife.Categories'; column does not allow nulls. INSERT fails.

    What have I done wrong and what can I do to fix please. Previously I could do this import ok with DTS on SQL 2000. Somehow it hasn't picked up the primary key on import.

  • ok, setting primary key on each table seems to have fixed it.

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

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