Sunday, February 19, 2012

inserting nulls into a primary key

The Question is ...Is there a way or work around to inserting a blank values into a primary field PLZ HELP.A blank is ok but null is NOT allowed. See BOL under the subject of 'Creating and Modifying PRIMARY KEY Constraints'|||One would think not. Primary keys are unique by definition. If you need to be inserting blank values into a primary key that field/column probably isn't your primary key.|||thank ..but could you show me in code how to do this.|||Hey, but he would only be able to put in one...

Where did I put that thread...|||the thing is that my warehouse requires this as this is a modification i only need to know how to insert that blank spot in that primary key any help would be very much aprreciated|||Here it is...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=31801

Can you post the DDL of your table?

And you can insert a blank in to a pk...but only once

If it's a composite (col, col2) Then only once for the unique occurance of col1, and so on...

Maybe if you explain why you need to do this...|||Primary keys aren't even ALLOWED to accept nulls. The closest you could come would be using a zero-lengths string on a character-based primary key, but again you would only be able to insert one record.

You can't do what you are trying to do, but I suspect that the problem lies in your database design than in SQL Server's limitations.

No comments:

Post a Comment