Question: how do i fix my SQL error 61-- Create variables to hold the start and end date 62 -peclare @startDate datetime :01/01/1998 63 Declare@endoate datetime='12/31/1999'

how do i fix my SQL errorhow do i fix my SQL error 61-- Create variables to hold

61-- Create variables to hold the start and end date 62 -peclare @startDate datetime :01/01/1998 63 Declare@endoate datetime='12/31/1999' 64Use a while loop to add dates to the table 65 Declare @DateInProcess datetime 66 Set DateInProcess StartDate 67 Ewhile @DateInProcess @EndDate 68 Begin 69Add a row into the date dimension table for this date 70 SET IDENTITY_INSERT [dbo].DimDates ON 71Insert Into [dbo]. [DimDates] 72[Daykey], [USADateName], [Monthkey ], [MonthName ], [yearkey], [YearName]) 73 values 74 Cast(Convert (nvarchar (5e), @DateInProcess , 112) as int) -- [Datekey] 75 DateName( weekday, DateInProcess 76 ++ Convert (nvarchar (50), @DateInProcess 112) [USADateName] Left(Cast (Convert (nvarchar 50), @DateInProcess, 112) as int), 6)[Monthkey] DateName( MONTH, DateInProcess) + ear( DateInProcess) - [Yearkey] castea ) YearName ar @DateInProcess) as nvarchar(5e)[MonthName] 78 79 80 81Add a day and loop again 82 Set @DateInProcess Dateadd(d, 1, @DateInProcess 83 End 84 |-2e) Add additional lookup values to Dinates r (@DateInProcess) as nVarchar(50 82 % Msg 2627, Level 14, 3tate 1, Line 71 Violation of PRIMARY KEY constraint PK DiDates Cannot insert duplicate hey in object "dbo.DinDates'- The duplicate key value is (19900101) The statement has been terminated Msg 2627, Level 14, 3tate 1, Line 71 Violation of PRIMARY KEY constraint PK DiDates Cannot insert duplicate hey in object "dbo.DiDates'- The duplicate key value is (19900102) The t tement h been te minated Msg 2627, Level 14, 3tate 1, Line 71 Violation of PRIMARY KEf constraint PK DimDates". Cannot insert duplicate tey in object "dbo DiDates The duplicate tey value is (19900103) The statement has been terminated Msg 2627, Level 14, 3tate 1, Line 71 Violation of PRIMARY KEY constraint PK DiDates Cannot insert duplicate hey in object "dbo.DiDates'- The duplicate key value is (19900104) The t tement h been terminated Msg 2627, Level 14, 3tate 1, Line 71 Violation of PRIMARY KEY constraint PK DiDates Cannot insert duplicate hey in object "dbo.DiDates'- The duplicate key value is (19900105)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!