Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
misc
exam.security
microsoft_update_catalog
msdn.annotations
msdn.drgui.discussion
msdn.duwamish
msdn.general
msdn.magazine
msdn.soaptoolkit
msdn.webservices
msdntraining
opsmgr.connectors
opsmgr.sp1
technet
technet.howtofeedback
technet.howtoneeds
technet.magazine
technet.technettalks
  
 
date: Wed, 30 Jul 2008 21:15:01 -0700,    group: microsoft.public.technet        back       


Prevent Violation of PRIMARY KEY   
Hi,

I have the following stored procedure that I call from VB.NET. When I call 
the procedure from VB.NET I often get a violation of primary key error. I 
understand this error is raised because some data has previously been written 
to the table. However if I write an SQL statement and open a recordset in 
VB.NET using "Insert Into" the statement still executes but only copying 
unique records into the table. The stored procedure won't add any records - 
it just goes straight to error. Is there any way to have it insert the 
records that are unique and ignore those that are not unique? 

Thanks

Stored Procedure:

CREATE PROCEDURE dbo.spFlightList_History_Archive 

@FlightDate as nvarchar(8)

AS

Insert Into FlightArchive.dbo.tblFlightList_History (FlightHistoryID, 
FlightID, FlightDate)

Select FlightHistoryID, FlightID, FlightDate,
From Flight.dbo.tblFlightList_History

Where Flight.dbo.tblFlightList_History.FlightDate = @FlightDate
GO
date: Wed, 30 Jul 2008 21:15:01 -0700   author:   Darkman

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us