Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #445

Re: problem from proc call and autoincreasing key in using otl

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: problem from proc call and autoincreasing key in using otl
Date 2011-06-13 07:23 +0000
Organization Erland Sommarskog
Message-ID <Xns9F035F76A937CYazorman@127.0.0.1> (permalink)
References <3c4bb9a9-97ed-4a95-9982-2afd993017bd@34g2000pru.googlegroups.com>

Show all headers | View raw


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

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

problem from proc call and autoincreasing key in using otl white_ideal <whiteideal@gmail.com> - 2011-06-12 17:08 -0700
  Re: problem from proc call and autoincreasing key in using otl Erland Sommarskog <esquel@sommarskog.se> - 2011-06-13 07:23 +0000
    Re: problem from proc call and autoincreasing key in using otl Gene Wirchenko <genew@ocis.net> - 2011-06-13 07:28 -0700
      Re: problem from proc call and autoincreasing key in using otl Erland Sommarskog <esquel@sommarskog.se> - 2011-06-13 23:59 +0200
        Re: problem from proc call and autoincreasing key in using otl Henk van den Berg <me@myplace.net> - 2011-06-14 08:35 +0200
  Re: problem from proc call and autoincreasing key in using otl white_ideal <whiteideal@gmail.com> - 2011-06-13 15:13 -0700
    Re: problem from proc call and autoincreasing key in using otl Erland Sommarskog <esquel@sommarskog.se> - 2011-06-14 23:39 +0200
      Re: problem from proc call and autoincreasing key in using otl white_ideal <whiteideal@gmail.com> - 2011-06-14 15:36 -0700
        Re: problem from proc call and autoincreasing key in using otl white_ideal <whiteideal@gmail.com> - 2011-06-14 17:33 -0700
  Re: problem from proc call and autoincreasing key in using otl white_ideal <whiteideal@gmail.com> - 2011-06-14 17:34 -0700

csiph-web