Increment question

  • I have the following snippet of code:

    select 'L' as RECTYPE, identity(int, 1, 1)as JELINENO, '800002' as JENO, 'AJE' as JECODE,

    '2006' as FY,

     

    I am saving this output into a #Temp table and after using the information I am dropping the table.  The questions is, is there a way to increment the JENO by 1 each time the process runs?

     

    Thanks,

     

    Dave

  • This was removed by the editor as SPAM

  • You could "SELECT MAX(JENO)" & add 1 to it...







    **ASCII stupid question, get a stupid ANSI !!!**

  • I figured this out.  The answers is:

     

    (select max(JENO) + 1 from issuesreturns) as JENO,

  • right - except your alias 'JENO' would be after your select max(jeno) + 1...

    select (max(JENO) + 1) as JENO from issuesreturns







    **ASCII stupid question, get a stupid ANSI !!!**

  • If you define your temp table just make the column in question an Identity column.

     

    CREATE TABLE #temp Col1 int IDENTITY(1,1), col2 <datatype>...

     

    Then just dont include this column in your insert list.

Viewing 6 posts - 1 through 5 (of 5 total)

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