Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert/Select Clause Syntax

Status
Not open for further replies.

cmarch1

MIS
Apr 5, 2001
41
US
Can anyone assist me with the following?

I'll write it generically so I can be assisted better
with (****) being the problem code

Insert into Grants
( id,type,requestdate,project,budgetdate)
Select
a1,'B',getdate(), @dd, (****)
from vw_test
Where fiscalyear = @intFY

(****) should be
IF GrantAmount is Null
Set @newbudgetamount = budgetamount
Else
Set @newbudgetamount = grantamount
end

I've tried different combinations but I always get an error message about syntax
even with begin/ends

 
Try using a CASE construct rather than the IF block. Robert Bradley
teaser.jpg

 
still having no luck

do you have an example of a CASE statement for

IF GrantAmount is Null
Set @newbudgetamount = budgetamount
Else
Set @newbudgetamount = grantamount
end

remembering I have to pass @newbudgetamount after I evaluate grant amount

 
After testing and debugging results, I got it.....thanks for the input
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top