Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: problem from proc call and autoincreasing key in using otl Date: Mon, 13 Jun 2011 07:23:03 +0000 (UTC) Organization: Erland Sommarskog Lines: 21 Message-ID: References: <3c4bb9a9-97ed-4a95-9982-2afd993017bd@34g2000pru.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Mon, 13 Jun 2011 07:23:03 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="G7+Jz22XqYCG8C6rb1H3YA"; logging-data="28766"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OyBlZyjM8vKEjrKuaoyK+" User-Agent: Xnews/2005.10.03 Mime-proxy/1.4.c.4 (Win32) Cancel-Lock: sha1:sj9QxyajpTYNi9EiXXRkbM8iA+s= Xref: x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:445 white_ideal (whiteideal@gmail.com) writes: > 1. how to get the autoincreasing identity immediately after inserting > a row? I how you can give me the answer within mysql and sqlserver. In SQL Server, use scope_identity(), which must be in the same batch as the INSERT statement. For MySQL, you need to ask in an MySQL forum. > 2. why the following code is error with "invalid cursor state"? > the source code is like this. I will have to admit that I have never seen this OTL before. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx