Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I'm using a direct query SQL in PBI. While using a DECLARE statement, it throws an error
Incorrect syntax near the keyqord 'DECLARE'. Incorrect syntax near ')'
My SQL statement is as follows:
DECLARE @effect_date as date;
Set @effect_date= (select distinct effective_date from in.input_table)
select * from abc
join ....
group by....
Any help is greatly appreciated.
Hey if anyone still looking for solution try to change your query , use cte instead of declare .
using declare :
DECLARE @effect_date as date;
Set @effect_date= (select distinct effective_date from in.input_table)
select * from abc
join ....
group by....
using cte:
WITH date AS (
SELECT
distinct effective_date from in.input_table AS effect_date)
SELECT * FROM date
hope it helps
Hi @Anonymous ,
Can this query return data correctly in SSMS?
Best Regards,
Jay
@Anonymous can you try this
DECLARE @effect_date date= (select distinct effective_date from in.input_table)
select * from abc
join ....
group by....
@Anonymous , This you can use as sub query, Try that way
select * from abc
join ....
where date in (select distinct effective_date from in.input_table)
group by....
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 44 | |
| 43 | |
| 38 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 64 | |
| 31 | |
| 29 | |
| 24 |