Solved

Inserting UniqueIdentifier results in null value

Posted on 2009-05-05
6
264 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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