unable to insert row into table with uniqueidentifier column

  • I just inherited a system that uses merge replication, I am trying to insert some rows into a table that is replicated and I am getting the following error.

    Server: Msg 515, Level 16, State 2, Line 1

    Cannot insert the value NULL into column 'directoryId', table 'MMSMail.dbo.DirectoryHierarchy'; column does not allow nulls. INSERT fails.

    The statement has been terminated.

    Here is the inset statement:

    Insert into DirectoryHierarchy(ParentDN,RDN,Type)

    select ParentDN, (FirstName + ' ' + LastName) as RDN, 3 from tempmms where directoryid is null and MMSAction = 'I'

    go

    I am not familar with merge replication.  I need to insert about 13,000 rows into multiple tables. How do I deal with the uniqueidentifer row?  I would appreciate any help.

  • If the Unique Identifier column does not allow nulls, you need to insert a value. 

     

    Insert into DirectoryHierarchy(directoryId,ParentDN,RDN,Type)

    select NEWID() as DirectoryID, ParentDN, (FirstName + ' ' + LastName) as RDN, 3 from tempmms where directoryid is null and MMSAction = 'I'

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Thanks alot!! that did the trick. 

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

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