Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 errorimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions