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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with VB and Sybase TSQL

Status
Not open for further replies.

goldi

Programmer
Mar 21, 2001
31
0
0
US
I use VB6.0 to connect to a Sybase database. I have some sql that works with an Access Database, but will not work with the Sybase.

The sql looks like this:

SELECT HeaderTable.SwisCode, DetailTable.ParcelNumber, Sum(IIf(HeaderTable.SchoolOrVillage = 'S',round(DetailTable.BaseTax+DetailTable.FeeAmount,2),0)) AS school_relevy, Sum(IIf([HeaderTable].[SchoolOrVillage] = 'V', round(DetailTable.BaseTax+DetailTable.FeeAmount,2),0)) AS village_relevy
FROM HeaderTable INNER JOIN DetailTable ON HeaderTable.HeaderKey = DetailTable.HeaderRecNo
GROUP BY HeaderTable.SwisCode, DetailTable.ParcelNumber;

I put this sql into a string variable and issue the open method. It doesn't like the IIf(). I have looked through the Adaptive Server Anywhere SQL reference and that was of no help.



 
Haven't worked with Sybase in many moons, but T-SQL doesn't incorporate the IIf() [from Jet SQL, as you pointed out]. Use a SELECT CASE instead.
 
Worked beautifully! I didn't realize that you could put expressions like that into SQL statements.

Thank you!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top