Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Random Null values

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-08-06 : 11:06:01
Hey all,

Sometimes when I create a DB and then a table, I define the fields and wont set any of them to null.

Then when I go into the query analyzer and start adding data, one of the fields will say "NULL" and there is naff I can do about it...

Does anyone else have this and no how to deal with it>?

mr_mist
Grunnio

1870 Posts

Posted - 2004-08-06 : 11:11:21
Can you give an example? I don't think sql server randomly goes about changing not null columns to nullable...

-------
Moo. :)
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-08-06 : 11:13:25
Ok,

I create a database, test....

create a table,

userName
loginName
password
department

userName as the primary key... none are null.

When I go to enter data department will say "NULL" in it.... sounds so silly I know, but trust me I dont have null values checked anywhere, but it still says null :( really unhappy
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2004-08-06 : 11:26:59
How are you creating the tables? Enterprise Manager? The default is allow nulls. Do you turn this off?

What is the output from right-clicking on the table and generating the sql script for it?

-------
Moo. :)
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-08-06 : 11:35:55
Yes I am creating in EM, I dont understand when you say right click the table and generate the script I cant see that... this is so weird.
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-08-06 : 11:42:10
Here are some screens if they help...




Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-06 : 13:08:02
It won't let you save it until you change the value.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2004-08-07 : 04:58:00
I think the problem is that when you open a table in QA for input, it won't let you edit text columns. When you add a new row, the only thing it will let you put in the text column is the default value, which is a bit of a bugger if there's no default set and the column isn't NULLable.
If you put DEFAULT '' on your text column, QA will still display NULL before it saves the row, and it still won't let you enter any data in the column, but it will save the row with the default value of '' in that column. You won't be able see that while entering the data though, since it will show non-NULL text values as (...)
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-08-09 : 04:39:29
so would it be better to use something other than text? nchar for example?
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-08-10 : 10:02:03
easily corrected... simply my n00bishness
Go to Top of Page
   

- Advertisement -