Re: One Insert statement, no looping, creates 2 records?
From: Steve Kass (skass_at_drew.edu)
Date: 07/20/04
- Next message: Roji. P. Thomas: "Re: Advanced SQl Programming links"
- Previous message: Ilya Margolin: "Re: Bulk Insert and Unique index question"
- In reply to: EPPack: "One Insert statement, no looping, creates 2 records?"
- Next in thread: EPPack: "Re: One Insert statement, no looping, creates 2 records?"
- Reply: EPPack: "Re: One Insert statement, no looping, creates 2 records?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 20 Jul 2004 08:54:08 -0400
Is there any chance a distributed query is involved? In some
circumstances, you can see this when the first execution generates the
metadata, and the second retrieves the results. This quote is from
http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlole.mspx:
If *IDBSchemaRowset* is not supported with TABLES, COLUMNS, and
TABLES_INFO rowsets, SQL Server opens the rowset against the base table
twice: once during query compilation to retrieve meta data, and once
during query execution. Providers that incur side effects from opening
the rowset (for example, run code that alters the state of a real-time
device, send e-mail, run arbitrary user-supplied code) must be aware of
this behavior.
Steve Kass
Drew University
EPPack wrote:
>Relatively new to SQL Server 2K. Have an .asp web page where I collect info
>from a simple form, pass it to a 2nd .asp via standard request variables,
>and insert a record into a table. I have a debug-type response.write display
>showing the actual insert code (to assist with syntax issues) right after
>the record gets created, and the record gets created uneventfully except for
>one minor issue. It's inserted twice most of the time! The auto-generated
>key increments, but the rest of the record is definitely identical. What's
>REALLY odd, tho, is that the debug display only shows once, even tho it's
>directly (before or) after the cn.execute statement, and the program is
>straight line, it does not loop. There is only one insert statement in the
>entire program. All objects are correctly named and closed and used with the
>correct set of statements. An email is built and sent in the program
>directly after the record is created, and IT gets sent twice too, even tho,
>again, only one debug message there shows up.
>
>I'm at a loss to figger out how something like this could even be happening.
>I've done LOTS of programs like this, but this is the first one that's done
>this, so I'm not even sure what to look for. I've put in displays, stepped
>it thru with displays, etc etc, but nothing seems to be triggering that 2nd
>write and email.Something MUST be, tho, 'cause the 2nd record and email are
>definitely there. Since the program isn't looping, and the debug display
>only comes out once, it almost seems like there may be something in the db
>or table itself (or the server?) that might be causing duplication, but I
>have no idea what to even look for :( Doesn't explain the double email tho
>:( It looks just as if the program is executing twice, as far as the Insert
>statement and the email is concerned, but only once for the display
>statements. Weird.
>
>I would appreciate any ideas.
>
>
>
- Next message: Roji. P. Thomas: "Re: Advanced SQl Programming links"
- Previous message: Ilya Margolin: "Re: Bulk Insert and Unique index question"
- In reply to: EPPack: "One Insert statement, no looping, creates 2 records?"
- Next in thread: EPPack: "Re: One Insert statement, no looping, creates 2 records?"
- Reply: EPPack: "Re: One Insert statement, no looping, creates 2 records?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|