January 7, 2013 at 10:12 am
Processing Database Procedural Code insert_into_agency_deplo_plan failed.
declare @nCount int
select @nCount = COUNT(*) from agency_deplo_plan
if @nCount = 0
BEGIN
insert into agency_deplo_plan (ag_id, deplo_plan_name)
select ag_id, act_pln
from AGENC;
END
Error message: One or more errors occurred during processing of command. Cannot find either column "dbo" or the user-defined function or aggregate "dbo.get_dts", or the name is ambiguous.
I tried separating it into 2 different insert statements (1 at a time), but then it tells me that :
(my SQL statement):
insert into agency_deplo_plan (deplo_plan_name)
select act_pln
from AGENC;
Error:
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'ag_id', table 'elPaso.dbo.agency_deplo_plan'; column does not allow nulls. INSERT fails.
The statement has been terminated.
This makes no sense because the column agency_deplo_plan doesn’t contain any NULL values, and neither column allows NULLs.
Thanks,
John
January 7, 2013 at 10:20 am
Are you sure this is all the code? The error doesn't tie up with the code:
declare @nCount int
select @nCount = COUNT(*) from agency_deplo_plan
if @nCount = 0
BEGIN
insert into agency_deplo_plan (ag_id, deplo_plan_name)
select ag_id, act_pln
from AGENC;
END
Error message: One or more errors occurred during processing of command. Cannot find either column "dbo" or the user-defined function or aggregate "dbo.get_dts", or the name is ambiguous.
dbo.get_dts doesn't show in the above query?
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
January 7, 2013 at 10:21 am
I know which is confusing to me. I'm running an auto update utility provided by my company, so maybe it is a stored procedure?
January 7, 2013 at 10:29 am
insert into agency_deplo_plan (deplo_plan_name)
select act_pln
from AGENC;
Error:
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'ag_id', table 'elPaso.dbo.agency_deplo_plan'; column does not allow nulls. INSERT fails.
The statement has been terminated.
The above inserts a value in the deplo_plan_name but you don't insert ag_id and because you said the column doesn't allow NULLs then SQL Server will naturally throw an error. Hope this makes sense.
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
January 7, 2013 at 10:34 am
Does it matter that i left out ag_id from that query? Also, it doesn't contain any NULLs, so why would SQL Server have a problem with it?
January 7, 2013 at 10:58 am
I tried
update dbo.agency_deplo_plan
set ag_id=agenc.ag_id
but I get the error:
The multi-part identifier "agenc.ag_id" could not be bound.
January 7, 2013 at 11:46 am
Ag_id is likely to be the primary key of the table you're trying to insert into. This is the error you posted earlier:
Cannot insert the value NULL into column 'ag_id', table 'elPaso.dbo.agency_deplo_plan'; column does not allow nulls. INSERT fails.
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
January 7, 2013 at 11:56 am
ag_id is the PK for table agenc, but not for agency_deplo_plan
January 7, 2013 at 12:04 pm
there is constraint on the table which doesn't allow this column to be NULL. This is to maintain referential integrity. You're attempting to insert a value in one column so SQL server tries to insert NULLs in the other columns. In this the value NULL violates the constraint so sql server throws an error.
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
January 7, 2013 at 12:08 pm
Ok, now it makes sense, sorry I am but a lowly noob, ha. Are there any workarounds or am I SOL?
Thanks for the help.
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply