Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vision.v1
Yak Posting Veteran
72 Posts |
Posted - 2011-03-14 : 08:26:41
|
Hi,In my database i have some tables with prefix 'rpt', some of these tables having a column(empno) with UNIQUE constraint.Now If some one trying to insert duplicate values for empno in any of the rpt tables i want to track what is the duplicate empno value trying to insert and in which 'rpt' table they are trying to insert, i want to insert this error information in some err tableplz give some idea..Thanks |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-03-14 : 15:05:57
|
How you are inserting the data in table ?1. Through Stored Procedure2. Preparing Insert statement and inserting3. Or other way |
 |
|
vision.v1
Yak Posting Veteran
72 Posts |
Posted - 2011-03-16 : 05:34:28
|
quote: Originally posted by pk_bohra How you are inserting the data in table ?1. Through Stored Procedure2. Preparing Insert statement and inserting3. Or other way 
I am using the cursor to read all the tables with prefix 'rpt' and in the cursor creating the UNIQUE key on field empno, but if the empno holding the duplicate values then the sp is terminating to avoid this i used the TRY...CATCH block.But in the catch block i am getting the errorMsg 1750, Level 16, State 0, Line 1Could not create constraint. See previous errors.but i want to know the Table Names which is having duplicate empno and the duplicate empNo values like the below one.Msg 1505, Level 16, State 1, Line 1The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.ct_Test5' and the index name 'UQ_ct_Test5_RTID_20110316052319'. The duplicate key value is (111).please give suggestion |
 |
|
|
|
|