2 Replies Latest reply on May 16, 2006 9:23 PM by The ScareCrow

    SQL question

    Level 7
      <cfquery name="cartID" datasource="#client.dsn#"
      username="#client.username#" password="#client.password#">

      insert into CART_ID (email, date_stamp) values ('#client.Admin#',
      '#DateFormat(CreateODBCDateTime(now()), "yyyy/mm/dd")#')
      </cfquery>

      There is an identity field in my CART_ID table that is a auto incremented
      identity field.

      With the following sql statement above is there a way to determine the
      identity field value that the records are put into without creating a whole
      new select query?


        • 1. Re: SQL question
          Level 7
          After some searching i found an answer that works

          <cfquery name="cartID" datasource="#client.dsn#"
          username="#client.username#" password="#client.password#">
          insert into CART_ID (email, date_stamp) values ('#client.Admin#',
          '#DateFormat(CreateODBCDateTime(now()), "yyyy/mm/dd")#')
          select SCOPE_IDENTITY() as value</cfquery>


          "bj" <orders@seton.net.au> wrote in message
          news:e4e3r7$j1h$1@forums.macromedia.com...
          > <cfquery name="cartID" datasource="#client.dsn#"
          > username="#client.username#" password="#client.password#">
          >
          > insert into CART_ID (email, date_stamp) values ('#client.Admin#',
          > '#DateFormat(CreateODBCDateTime(now()), "yyyy/mm/dd")#')
          > </cfquery>
          >
          > There is an identity field in my CART_ID table that is a auto incremented
          > identity field.
          >
          > With the following sql statement above is there a way to determine the
          > identity field value that the records are put into without creating a
          > whole new select query?
          >


          • 2. Re: SQL question
            The ScareCrow Level 1
            I would suggest removing the dateformat function and just pass the createodbcdatetime result

            Ken