Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Inserting UniqueIdentifier results in null value

Posted on 2009-05-05
6
Medium Priority
?
266 Views
Last Modified: 2012-05-06
So I have this table with a bunch of nullable fields. Amoung them is a uniqueIdentifier column(FK_ID)  that is also nullable. I also have an ID field(TableA_ID) which gets set by NewID() as the default value. I do an insert like so....

INSERT INTO [TableA](FK_ID)
SELECT NewID()
(1 row(s) affected)

I see the following result in TableA
FK_ID____________________________TableA_ID____________________________
Null                                                                      9326DC68-2303-4A12-B2CB-6458E215DFD4

Why can't I insert a uniqueidentifier?
0
Comment
Question by:rlstewart
6 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 24309076
so, fk_id doesn't have a value in it?  
0
 

Author Comment

by:rlstewart
ID: 24309103
A new row is added with the value null in the FK_ID field.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24309112
are you sure the field tablea_id has a default value of newid()??
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 60

Expert Comment

by:Kevin Cross
ID: 24309126
Is there a constraint on FK_ID that it must be NULL or a valid value from another table?
0
 
LVL 26

Expert Comment

by:tigin44
ID: 24309129
is the table trying to insert value a detail table? if so then you should insert the value for the master table. and then insert into the detail table.
0
 

Accepted Solution

by:
rlstewart earned 0 total points
ID: 24309216
Found the problem, there was a INSTEAD OF INSERT trigger that had left off the FK_ID column, hence the null value. DOH!!!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question