View Single Post
  #7 (permalink)  
Old May 2nd, 2007, 02:31 AM
bashiiui bashiiui is offline
Registered User
Join Date: Apr 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Yes, I have exactly same table schema and constraints on both sides thats where Violation of UNIQUE KEY constraint 'IX_dbTables' occurs. The point is that when the constraints are there, On violation into destination table on dkpc166, why I get following exception in query analyzer.

DECLARE @err int
EXECUTE sp_ExecuteSQL N'INSERT INTO dkpc166.f4aLocal.dbo.[dbTables] SELECT * FROM sql09.finance4all_alfa.dbo.[dbTables] WHERE Guid = ''51FCA305-BCD2-407F-8B40-290B32F2D74C'''
SELECT @err = coalesce(nullif(@err, 0), @@error)
IF @err <> 0
            Print 'Display error for testing'
            RaiseError (‘abc’, 15,-1)

ERROR Raised into Analyzer:
Server: Msg 2627, Level 14, State 2, Line 1
Violation of UNIQUE KEY constraint 'IX_dbTables'. Cannot insert duplicate key in object 'dbTables'.
The statement has been terminated.

Issue: Why Print statement is not get executed, how I am going to execute the Print statement?