October 19, 2005 at 9:57 am
When Iam trying to insert a table I am getting follwin mesg.
Server: Msg 515, Level 16, State 2, Line 4
Cannot insert the value NULL into column 'DiffReason', table 'PerfMeasure.dbo.QuarterlyEntry'; column does not allow nulls. INSERT fails.
The statement has been terminated.
I understand that I didnt allow NULLS for that column but I have set it to some default value,still i am getting this error.
October 19, 2005 at 10:01 am
if you do INsert into table (DiffReason) values (NULL), the default won't be used because you supplied a value (even if the value is null).
October 19, 2005 at 10:04 am
so..u want me to allow NULLS there and it works fine.
October 19, 2005 at 10:04 am
Indeed,
Instead of INsert into table (DiffReason) values (NULL)
try using the Default keyword
INsert into table (DiffReason) values (Default),
October 19, 2005 at 10:06 am
No, just don't include the column in the insert if you don't insert it. If this is a general statement, then you have to do something like this :
Insert into... values (ISNULL(@Varname), @DefaultValue))
October 19, 2005 at 10:06 am
FYI.. Iam not inserting particular values in it, I am inserting complete table from one DB to another
October 19, 2005 at 10:13 am
You'll hve to use the isnull technic... that's the simple way around this one.
October 19, 2005 at 10:16 am
Ok this is query..
INSERT INTO perfmeasure..Quarterlyentry
(
ProjectedQtr ,
Yr_EndProjected ,
Diff ,
DiffPercent ,
DiffReason ,
CorrectiveAction
 
SELECT
Projected_Qtr1 ,
Yr_EndProjected ,
Diff ,
DiffPercent ,
DiffReason,
CorrectiveAction
FROM PM..quarterlyEntry
October 19, 2005 at 10:17 am
SO???
Select..
isnull(Diffe, @Defaultvalue)
What are you not getting?
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply