Quantcast
Viewing all articles
Browse latest Browse all 4871

INSERT INTO? This should work

I am messing around with some things in a test database and came across something I would like to do. In the future I will have to update some information in a table with new dates and budget info. Here is my code...

USE REPORTING

DECLARE

@JAN MONEY = 100.00

INSERT INTO FACTBUDGET (BUDGETAMOUNT)

SELECT

CASE WHEN BUDGETDATEID 20141231 AND BUDGETDATEID < 20150201 AND MISCID = 0

THEN @JAN

ELSE 'BUDGET NEEDED'

END AS BUDGETDATEID

FROM FACTBUDGET

When I run this the variable goes into that column but to almost all records. Am i doing this the easiest way? I was thinking of creating a temp table but thought that would be too much data to create.The variables will be created for each month along with case statements. This way I only have to enter in the amounts when given, I have another instert statement created that I know works for the budget date.


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>