Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I need to use directquery to use parameter in slicer,
but my sql query is success in SQL SERVER but happen error when using direct query,
I have try to use -->select * from (.......my program......) as SourceQuery
still show error
"Microsoft SQL: Incorrect syntax near keyword 'declare'.
Incorrect syntax near ')'. "
I have so idea:(
I have the solution!
Convert your stored procedure to function that returns a table. It works!
Something like this:
create or alter function dbo.my_function()
returns @my_data table
(
Field1 varchar(20),
Field2 int,
Field3 int
)
as
begin
declare @test int
set @test = 1
insert into @my_data
select [Field1, Field2, Field3]
from [your table]
where Field3 = @test
return
end
@Lily36876 , You have to use select here. declare etc is not supported.
SP is supported, But not sure that can work direct query
thx For reply,that meas I can't use any declare in DQ?
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 63 | |
| 55 | |
| 41 | |
| 16 | |
| 14 |
| User | Count |
|---|---|
| 98 | |
| 80 | |
| 35 | |
| 29 | |
| 25 |