Click here to Skip to main content
15,879,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, when running part of your code for the DimDate of 1st data warehouse, I get an msg102 error:
From the beginning of the script to:
SQL
UPDATE @DayOfWeek
	SET 
		MonthCount = MonthCount + 1,
		QuarterCount = QuarterCount + 1,
		YearCount = YearCount + 1
	WHERE DOW = DATEPART(DW, @CurrentDate)

	SELECT
		@DayOfWeekInMonth = MonthCount,
		@DayOfQuarter = QuarterCount,
		@DayOfWeekInYear = YearCount
	FROM @DayOfWeek
	WHERE DOW = DATEPART(DW, @CurrentDate)


Msg 102, Level 15, State 1, Line 134<br />
Incorrect syntax near ')'.


But if I run the whole of the code. No error at all. Will you please shed some light on it? Many thanks.

What I have tried:

I tried to add ';' at the end of
SQL
WHERE DOW = DATEPART(DW, @CurrentDate)
, which does not work.
Posted
Updated 11-Feb-20 10:34am
v2
Comments
Patrice T 11-Feb-20 10:47am    
And line 134 is ?
Member 14645245 11-Feb-20 11:00am    
Hi, the line 134 is 'WHERE DOW = DATEPART(DW, @CurrentDate)'
thank you.
Richard Deeming 11-Feb-20 15:15pm    
.
Dave Kreskowiak 11-Feb-20 15:40pm    
"Your code"?? Which one of the 14,400,000 million on this site are you talking to?

The articles on this site are written by all volunteers, not by a few people at CodeProject. If you've got a question or problem with an article, ask it in the forum at the bottom of the article.

Assuming you're looking at the code from this article:
Create and Populate Date Dimension for Data Warehouse[^]

The part of the code you're trying to execute includes the start of a loop:
SQL
WHILE @CurrentDate < @EndDate
BEGIN
but doesn't include the closing part of the loop:
SQL
    SET @CurrentDate = DATEADD(DD, 1, @CurrentDate)
END
This will obviosuly produce the syntax error you saw:
plain
Msg 102, Level 15, State 1, Line 88
Incorrect syntax near ')'.
 
Share this answer
 
Don't post this under Quick Answers - if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them. And with 14,000,000 members here that could have written any one of many thousands of articles, tthat's unlikely ...
 
Share this answer
 
Dear Richard Deeming
Your solution makes perfect sense! Many thanks for your help. Much appreciated.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900