Converting Oracle built-in functions to SQL Server

  • I use this select statement:

    SELECT NVL(MAX (KEY),0) FROM JIDS_DATASOURCES)+1

    to get the next primary key for that table when i am inserting a new row in the table.

    How can i convert this over to SQL server and still get the same functionality???

     

    Tricia

  • The Oracle NVL and COALESCE functions behave identically but COALESCE is ANSI standard and is supported by SQL Server.

    This SQL will work for both Oracle and SQL Server

    SELECT COALESCE(MAX (KEY ) , 0 ) + 1

    FROM JIDS_DATASOURCES

    SQL = Scarcely Qualifies as a Language

  • Thanks

    Tricia

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply