Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good day!
Colleagues, is any way in QV script of using QV variable in SQL query ?
For example:
1. Current Load
Main:
Load
Period;
SQL SELECT *
FROM DataBase.dbo.DP3_Sales_Fact with (nolock)
where Period>='2016-08-01 00:00:00.000';
2.Neccessary Load
Main
Load
Period;
SQL SELECT *
FROM DataBase.dbo.DP3_Sales_Fact with (nolock)
where Period>=Current YearMonth;
In other words, in sql query i need load only Period for Current YearMonth (201608)
Thanks.
Try this:
LET CurrentYearMonth = Year(today()) & month(today());
Main
Load
Period;
SQL SELECT *
FROM DataBase.dbo.DP3_Sales_Fact with (nolock)
where Period>=$(CurrentYearMonth);
May be as below:
Main
Load *
Where Period = '201608';
SQL SELECT *
FROM DataBase.dbo.DP3_Sales_Fact with (nolock);
Try this:
LET CurrentYearMonth = Year(today()) & month(today());
Main
Load
Period;
SQL SELECT *
FROM DataBase.dbo.DP3_Sales_Fact with (nolock)
where Period>=$(CurrentYearMonth);
You can also use a variable in the sql part
Main
Load *;
SQL SELECT *
FROM DataBase.dbo.DP3_Sales_Fact
where Period >= $(vCurrentYearMonth);
You may need to use the TODAY() with some other functions in order to get the current Year & Month.
What is the date format in your Period field. ?
Thanks.
But Where operator in QV part of load table works longer as in SQL part.
Thanks!
'YYYY.MM.DD'
You might need to double-check this format.
Your original messages said the current load was :
1. Current Load
Main:
Load
Period;
SQL SELECT *
FROM DataBase.dbo.DP3_Sales_Fact with (nolock)
where Period>='2016-08-01 00:00:00.000';