Groups | Blog | Home
all groups > sql server programming > may 2007 >

sql server programming : Possible Corruption?


Steve Zimmelman
5/19/2007 6:35:43 PM
Hello,

I am using a this procedure to insert a record and return the value of the newly
inserted record's ID. ID is an Int Identity field and PK.

*****************
Create Procedure [dbo].[NewResRxOrder_SP]
@ResID int,
@AdmitDateID int
As
Insert Into [ResRxOrders]
([ResID],
[AdmitDateID])
Values
(@ResID,
@AdmitDateID)
/*** Return New Int ID [ID] ***/
Select SCOPE_IDENTITY() As NewID
***************

One of my beta testers is getting a value returned that is a already exists in
the table; and when the value is used in another relational table, it crashes
with a constraint error (as it should).

I have used DBCC DBREINDEX on all the tables, but the error persists.

I have never seen SQL Server do this, especially with a single install on a
computer for testing.

Anyone have any ideas how to fix this and/or prevent it?
We are using SQL Server 2000.

TIA,

-Steve-

Sylvain Lafontaine
5/19/2007 11:56:26 PM
Any big difference between the real value that should be returned and the
one that your beta tester is getting?

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


[quoted text, click to view]

Uri Dimant
5/20/2007 12:00:00 AM
Steve
It looks very strange because it must not happen. Does the tester open only
one session to un your SP? We need more details .
Can you reproduce the problem?



[quoted text, click to view]

Steve Zimmelman
5/21/2007 12:00:00 AM
Yes, only one session is used. We are using ADO with 1 connection.

No I can't reproduce the problem here. That's why I think there must be some
corruption someplace within SQL Server.


-Steve-

[quoted text, click to view]

Steve Zimmelman
5/21/2007 12:00:00 AM
Yes. The value that seems to getting stuck is 302. 302 exists in the table and
was added back in April. The number returned number should be around 340.

I should add we are using ADO with 1 connection object and placing a single
transaction around this SP and other updates that are related to this insert.

What's strange is that the crash doesn't occur until the value that is returned
by NewResRxOrder_SP is used to create a related record in another table. And
the returned value is clearly a duplicate.

-Steve-

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> wrote in
message news:uGwr5LpmHHA.1340@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]

Uri Dimant
5/21/2007 12:00:00 AM
Steve
Restore the backup ( from the days that you are sure that db was OK) and
try to re-run the query









[quoted text, click to view]

Sylvain Lafontaine
5/21/2007 11:20:34 AM
If possible, try to backup/restore (or even better, duplicate the database
using a software like RedGate) to another database and see if nothing
change.

Is this beta tester using the same database as everyone else or is he using
a private copy? Did you try to force a recompilation of the stored
procedures (or even better, to clear all caches: DBCC
FREEPROCCACHE, DBCC DROPCLEANBUFFERS).

Finally, are you using things like « SET IDENTITY_INSERT table ON » that
could have stick on? Does anything change is you set a « SET
IDENTITY_INSERT table OFF » at the beginning of the SP?

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


[quoted text, click to view]

Steve Zimmelman
5/21/2007 11:51:22 AM
[quoted text, click to view]
It's private copy installed on a laptop.

[quoted text, click to view]
No. But I guess that's a next step. Although these SP's haven't changed for
months.

[quoted text, click to view]
No, I don't use these statements anywhere.


[quoted text, click to view]

AddThis Social Bookmark Button