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 2008 Forums
 Transact-SQL (2008)
 column default value getdate() returns null?

Author  Topic 

Rene Balvert
Starting Member

3 Posts

Posted - 2010-11-01 : 07:13:31
We have a .NET application that imports ascii files, running for years.

Today we got 'insert failes cannot insert value NULL into column 'Updated', columns does not allow nulls' for two different tables.

In both tables this field has the default value GETDATE(), and we are not using this field at all in our insert statements. It always gets the default value.

It happend only 42 times on a over 10.000 inserts in 3 different timeframes, 01:25, 10:19 and 11:03.

In the SQL log and event vieuwer there is no error.

Any clue?

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-01 : 07:43:57
You'll need a profile trace to see exactly what happens. Without seeing exactly what's running, it's hard to say.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

Rene Balvert
Starting Member

3 Posts

Posted - 2010-11-01 : 07:56:43
it is not reproducable so far, but we are switchin on profiler now
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-01 : 10:33:47
Trace T-SQL Batchcompletion, SP:RPCCompletion and the error events.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-11-01 : 11:49:39
The most likely cause is that the INSERT statement explicitly tried to insert a null value.

Are the INSERT statements being generated in the front-end code?




CODO ERGO SUM
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-11-01 : 15:51:24
who produces these ascii files? Do you have a validation process on these ascii files? in case columns have been deleted, changed and/or added. Also column ordinal position? like a DTD for xml?

check against a previous ascii file to see if something changed.

If you don't have the passion to help people, you have no passion
Go to Top of Page

Rene Balvert
Starting Member

3 Posts

Posted - 2010-11-01 : 19:43:58
The insert statement is something like insert table (column1, column2) values ( val1, val2), the default column is not inserted.

It is executed through ADO.NET SQLCOMMAND.

The import application open multiple threads to speed up import, we can process 50mb in seconds. We had issues with a stored procedure that was called with the same data from different threads:

if (exists)
insert ..
else
update ..

Both threads passed the if (exists), but one of the threads failed with PK constraint. We solved it with an exclusive sp_getapplock, this let only one threads at the time.

We are profiling but so far the problem didn't occur anymore.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-01 : 20:06:03
There are no miracles, something was changed...

And giving us..."the statement is like..." won't cut it

We need to SEE the actual statement

Also, I would imagine, that if you had strong change control, you will know what has changed...

There are no miracles...something changed..either with the db, or the code, or someone added new code



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx





Go to Top of Page
   

- Advertisement -