tags:

views:

243

answers:

2

I'm connected to an OpenEdge DataServer via ODBC (not our product, we are just accessing their database, I hardly have any information and certainly no help from the other side).

Anyhow, I just need to execute a simple Select, add a couple of rows and I need the equivalent of an IsNull statement.

Basically I'd like to execute

SELECT ISNULL(NULL,'test')

This fails with a Syntax Error. I've looked around at something they misleadingly call a "documentation" but there are only references to SP_SQL_ISNULL but I can't get that to work either. I'm fit in T-SQL, so any pointers in any direction appretiated, even if it's just a RTFM with a link to TFM :)

Thanks

+1  A: 

I am not 100% sure, but I think ODBC driver expects a valid SQL statement, and not an DBMS specific SQL statement, like the one you provided.

Cătălin Pitiș
Could you explain further? Do you mean I should be running the select on a table. I am actually just doing SELECT ISNULL(CountMe,0) + ISNULL(CountMe2,0) FROM TableThanks
AlexDuggleby
+1  A: 

Thanks to Catalin and this question I got on the right track. I kept thinking I needed a OpenEdge specific function but actually I needed to use only ODBC SQL syntax.

To get what

ISNULL(col,4)

does you can use

COALESCE(col,4)

which "returns the data type of expression with the highest data type precedence. If all expressions are nonnullable, the result is typed as nonnullable."MSDN

Basically it will convert to 4 if the value is null (and therefore not convertable).

AlexDuggleby