May 25, 2011 at 6:12 am
Here is my sql statement:
INSERT INTO DatabaseBackupHistory (Information) Values ('OK')
Here is the error I'm receiving:
Cannot insert the value NULL into column 'RunDT', table 'BackupDW.dbo.DatabaseBackupHistory'; column does not allow nulls. INSERT fails.
Why is the statement attempting to insert into RunDT?
May 25, 2011 at 6:13 am
nvm, i'm an idiot. I need some coffee
May 25, 2011 at 7:58 am
Is RunDT in your table or is there a trigger on the table?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
May 25, 2011 at 9:12 am
1 of 2 things:
1. You have a trigger on your table that is attempting to do stuff on insert or
2. (More Likely) You have a column named RunDT in your table that is set to Not NULL and which does not have a default value.
My guess is that the RunDT column in your table is the Run Date and you need to ensure that it has a value. I would suggest that you put a default value of GetDate() into the column's definition, thereby allowing you to use the INSERT command exactly as written - unless you have a few more NOT NULL columns to contend with.
May 25, 2011 at 9:21 am
Please provide the DDL for the table.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
May 25, 2011 at 9:35 am
jshurak (5/25/2011)
nvm, i'm an idiot. I need some coffee
I think this means that he figured out the problem... like include all columns in the insert!
May 25, 2011 at 10:37 am
Ninja's_RGR'us (5/25/2011)
jshurak (5/25/2011)
nvm, i'm an idiot. I need some coffeeI think this means that he figured out the problem... like include all columns in the insert!
Or at least the ones that don't allow nulls and that don't have defaults...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 25, 2011 at 10:42 am
WayneS (5/25/2011)
Ninja's_RGR'us (5/25/2011)
jshurak (5/25/2011)
nvm, i'm an idiot. I need some coffeeI think this means that he figured out the problem... like include all columns in the insert!
Or at least the ones that don't allow nulls and that don't have defaults...
That was my "fill in the blanks" answer for today. :hehe:
May 25, 2011 at 10:45 am
Ninja's_RGR'us (5/25/2011)
WayneS (5/25/2011)
Ninja's_RGR'us (5/25/2011)
jshurak (5/25/2011)
nvm, i'm an idiot. I need some coffeeI think this means that he figured out the problem... like include all columns in the insert!
Or at least the ones that don't allow nulls and that don't have defaults...
That was my "fill in the blanks" answer for today. :hehe:
:w00t:
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 26, 2011 at 5:35 am
No no no. It was simpler than that. Insert statements are for rows that don't already exist in the database......update statements are for rows that do already exist.
A bit of a facepalm moment. Like I said....I needed coffee...I swear that was it
May 26, 2011 at 5:45 am
jshurak (5/26/2011)
No no no. It was simpler than that. Insert statements are for rows that don't already exist in the database......update statements are for rows that do already exist.A bit of a facepalm moment. Like I said....I needed coffee...I swear that was it
Even worse better than what I had imagined! :pinch:
May 26, 2011 at 6:20 am
Ninja's_RGR'us (5/26/2011)
jshurak (5/26/2011)
No no no. It was simpler than that. Insert statements are for rows that don't already exist in the database......update statements are for rows that do already exist.A bit of a facepalm moment. Like I said....I needed coffee...I swear that was it
Even
worsebetter than what I had imagined! :pinch:
Oh, of course. Why, that's just so obvious! ;-):w00t:
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 30, 2011 at 7:59 am
As per your information provided
Cannot insert the value NULL into column 'RunDT', table 'BackupDW.dbo.DatabaseBackupHistory'; column does not allow nulls. INSERT fails
this is happening cause of in your table DatabaseBackupHistory, RUNDT is having not null constraint.
and you are not providing value for that.
check your table schema
better to write insert script with all columns.
May 31, 2011 at 7:38 pm
Hmmm. Someone else a tad slow on the uptake maybe ...? 😀
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply