Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I have an Empty field

Status
Not open for further replies.

srajeevkumar

IS-IT--Management
Dec 29, 2003
36
GB
Hello,

Is it possible to set field datatypes to not to allow Nulls , but can allow Empty ( "" ) values. In MS Access thats how we overcame the problem these Nulls were causing us lot. But in SQl server it seems so far that a field can never be empty , it either has some value or has to be Null.
Having Null values in field is giving us a nightmare on displaying various database fields on screen and also when exporting such Null values records into a Text file for some purposes.

Any suggestions tips or tricks are more than welcome.

Rgds

Rajeev
 
"" is an actual value. SQL server doesn't concider this any different then "Bob". If you don't want NULL's then you have to define the column as NOT NULL. Another thing you can do is provide default values. The issue is you could change the columns as NOT NULL but if you only do that then you'll probably crash when your programs don't supply a value.

So set the columns to NOT NULL and put in a default value of ''.

 
You could also use ISNULL in selectstatements that you might have for retreiving data.

for instance

field1 in table1 has NULL as value.



select ISNULL(field1,'') as field1 from table1

this will then return '' as value instead of NULL

But I am not sure if you are looking for something like this.

Atomic Wedgie

 
thanks very much I think this statement will hep in the ivalid use o Null errors when I am displaying data.

Rgds

Rajeev
 
Oh I see you are having a problem like in VB where you have a statement of
MiddleInit.Text = rs.fields("MI").value

try this

MiddleInit.Text = rs.fields("MI").value & vbNullString
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top