I am using Visual Studio 2008 and Sql Server 2005
I want to update a table using values from other table
I have written a query but it is giving error
“Cannot insert the value NULL into column ‘Quantity’, table ‘Stationarymgmt.dbo.Item_Master’; column does not allow nulls. UPDATE fails.”
temp table has following columns
Item_Code,
Quantity,
Cost ,
Name ,
Decription,
Item_Master table has follwing Columns
Item_Code,
Name,
Decription,
Cost ,
Quantity,
The query is
UPDATE Item_Master,temp
SET Item_Master.Quantity = Item_Master.Quantity - temp.Quantity where Item_Master.Item_Code = temp.Item_Code
Please help me out
You could rewrite it using SQL Server’s
update ... from:The
wherecondition should filter out rows fromtempwhich lack a quantity.