Question : Error Calling Stored Proc

Experts,

Calling my stored proc (attached) from a script gives me this error:

Msg 8106, Level 16, State 1, Procedure spScheduleAppointmentTypePopulate, Line 6
Table 'ScheduleAppointmentType' does not have the identity property. Cannot perform SET operation.

What's going on?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spScheduleAppointmentPopulateSingle')
	BEGIN
		DROP  Procedure  spScheduleAppointmentPopulateSingle 
	END

--SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
  CREATE PROCEDURE [dbo].[spScheduleAppointmentPopulateSingle]
	@CenterID int	
  AS
  SET NOCOUNT ON


SET IDENTITY_INSERT ScheduleAppointment ON 
INSERT INTO ScheduleAppointment 
(
ScheduleAppointmentID
,ScheduleRoomID
,ScheduleAppointmentTypeCode
,PopulationTaskID
,StartTime
,DurationMinutes
,AgentID
,Transportation
)
SELECT 
a.AppointmentID
,acra.AssessmentCenterRoomID
,at.Type
,a.PopulationTaskID
,DateStartTime
,datediff(mi, a.DateStartTime, a.DateEndTime) 
,a.AgentID
,Transportation
FROM Appointment a
INNER JOIN AssessmentCenterRoomAppt acra
ON a.AppointmentID=acra.AssessCenterRoomApptID 
JOIN AppointmentType at 
ON a.AppointmentTypeID = at.AppointmentTypeID 
INNER JOIN AssessmentCenterRoom acr ON acr.assessmentCenterRoomID=acra.AssessmentCenterRoomID
WHERE acr.AssessmentCenterID=@CenterID

SET IDENTITY_INSERT ScheduleAppointment OFF

Answer : Error Calling Stored Proc

seems like there is no identity columns defined in the SceduleAppointment table


  CREATE PROCEDURE [dbo].[spScheduleAppointmentPopulateSingle]
      @CenterID int      
  AS
  SET NOCOUNT ON


INSERT INTO ScheduleAppointment
(
ScheduleAppointmentID
,ScheduleRoomID
,ScheduleAppointmentTypeCode
,PopulationTaskID
,StartTime
,DurationMinutes
,AgentID
,Transportation
)
SELECT
a.AppointmentID
,acra.AssessmentCenterRoomID
,at.Type
,a.PopulationTaskID
,DateStartTime
,datediff(mi, a.DateStartTime, a.DateEndTime)
,a.AgentID
,Transportation
FROM Appointment a
INNER JOIN AssessmentCenterRoomAppt acra
ON a.AppointmentID=acra.AssessCenterRoomApptID
JOIN AppointmentType at
ON a.AppointmentTypeID = at.AppointmentTypeID
INNER JOIN AssessmentCenterRoom acr ON acr.assessmentCenterRoomID=acra.AssessmentCenterRoomID
WHERE acr.AssessmentCenterID=@CenterID

Random Solutions  
 
programming4us programming4us