سؤال

I am using SQL Server Compact Edition as database for my Windows Application. I am having a problem while using ISNULL. I wrote a query

SELECT 
    ISNULL(MAX(TransactionID) + 1, 100) AS TransactionId 
FROM
    TBLTransactionMain

But this query returns only true or false. Is there anything I can do to get the same result as in SQL Server 2008?

هل كانت مفيدة؟

المحلول

You need to use coalesce http://technet.microsoft.com/en-us/library/ms174075.aspx

The syntax is the same as the isnull.

نصائح أخرى

The question is somewhat vague, but if your goal is to assume a value if TransactionID is NULL, then something like this is what you need:

MAX( ISNULL( TransactionId, 0 ) + 1, 100 ) AS TransactionId

Otherwise, you may need to clarify.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top