Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
dineshm030
Creator III
Creator III

SQL Query In QlikView Script

Hi All,

I am trying to execute the SQL query in QlikView Script. The below error is showing in QlikView as well as same query is running SQL Server.

dineshm030_0-1623232574411.png

SQL
DECLARE @StartDimDate date = '$(@StartDimDate)';
SQL
DECLARE @CutoffDimDate date = DATEADD(DAY, -1, DATEADD(YEAR, 5, '$(@StartDimDate)'));
SQL
WITH seq(n) AS
(
SELECT 0 UNION ALL SELECT n + 1 FROM seq
WHERE n < DATEDIFF(DAY, '$(@StartDimDate)', @CutoffDimDate)
),
d(d) AS
(
SELECT DATEADD(DAY, n, '$(@StartDimDate)') FROM seq
),
src AS
(
SELECT
Date_Key = CAST(CONVERT(varchar(8),d,112) AS int),
TheDate = CONVERT(date, d),
TheDay = DATEPART(DAY, d),
Day_of_Week_Eng = DATENAME(WEEKDAY, d),
TheWeek = DATEPART(WEEK, d),
TheISOWeek = DATEPART(ISO_WEEK, d),
TheDayOfWeek = DATEPART(WEEKDAY, d),
Calendar_Month = DATEPART(MONTH, d),
TheMonthName = DATENAME(MONTH, d),
TheQuarter = DATEPART(Quarter, d),
Calendar_Year = DATEPART(YEAR, d),
TheFirstOfMonth = DATEFROMPARTS(YEAR(d), MONTH(d), 1),
TheLastOfYear = DATEFROMPARTS(YEAR(d), 12, 31),
TheDayOfYear = DATEPART(DAYOFYEAR, d),
Days_In_Month = MAX(DATEPART(DAY, d)) OVER (PARTITION BY DATEPART(YEAR, d), DATEPART(MONTH, d))
FROM d
);
SELECT * into #Dim_Date FROM src
ORDER BY TheDate
OPTION (MAXRECURSION 0);

1 Reply
NadiaB
Support
Support

Hi @dineshm030 

Have you tried with a different diver? I would probably try the SQL server native one with ODBC DSN.

https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-serve...

The following article shows the odbc dsn part:

How to test an ODBC and OLEDB Connection without Qlik Products SQL Server
https://support.qlik.com/articles/000085290

Then you just need to create an ODBC connection from QlikView.

Hope it helps.

 

Don't forget to mark as "Solution Accepted" the comment that resolves the question/issue. #ngm