Solved

Inserting UniqueIdentifier results in null value

Posted on 2009-05-05
6
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 59

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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