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!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live 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?
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 50 | |
| 41 | |
| 32 | |
| 26 | |
| 24 |
| User | Count |
|---|---|
| 131 | |
| 118 | |
| 58 | |
| 45 | |
| 43 |