Posts

Showing posts from August, 2001

SQL To Return Identity when Inserting

When inserting an identity value, use @@Identity to return the id. Replace myTable with you table name, myField with your field name, myValue with a valid value for your field. Make sure you have an identity row defined and set to auto. @@Identity will return the ID inserted into that row. ----Begin SQL---- Insert into myTable (myField) Values (myValue); Select @@Identity ----End SQL---- About the Author Emmanuel Tsouris is a Systems Management veteran and Developer Advocate specializing in PowerShell and Cloud Automation. He maintains DotVBS to preserve legacy knowledge for the "archaeologist admin." Ready to move from VBScript to the Cloud? Check out his book, Pro PowerShell for Amazon Web Services . Visit EmmanuelTsouris.com for his latest projects. As an Amazon Associ...