View Full Version : Any error with this syntax?


pradaloh
06-27-2007, 12:40 AM
Hi All,

As I am really 'Green' in this line, can anyone tell me what wrong with my syntax?

Thanks in advance.


INSERT INTO Depreciation (AssetID,DepreciationAmount,DepreciationDate)
SELECT Assets.AssetID,
CASE WHEN Assets.AssetID FROM Assets not in (SELECT Depreciation.AssetID FROM Depreciation) THEN Month(Assets.DateAcquired)*SLN(Assets.BookValue,As sets.SalvageValue,Assets.DepreciableLife)/12
ELSE SLN(Assets.BookValue,Assets.SalvageValue,Assets.De preciableLife)/12
END,
Format(Me!DepnRunDT, "0")
FROM Status INNER JOIN Assets ON Status.StatusID=Assets.StatusID
WHERE ((Assets.StatusID)=1);

garethl
06-27-2007, 02:56 AM
i'm pretty new to this two but i think that if you use

INSERT INTO followed by SELECT then you need to select all the fields you want to insert

i.e. you want to insert 3 fields AssetID,DepreciationAmount,DepreciationDate

and you've only selected one

Assets.AssetID

i could be wrong though and there could well be other errors too