Solved

Inserting UniqueIdentifier results in null value

Posted on 2009-05-05
6
259 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this article I will describe the Backup & Restore 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 this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now