Forum Discussion
Issue while using stored procedure in SQL server database
- Anonymous1 year ago
Hi powerbidev123 ,
Thanks for the reply from girishthimmaiah .
Assuming that your
Server = X
Database = Y
Table name = Z
The sample SQL query is (as if you put it on SSMS)
select * from z WHERE [customerid]=2The conversion to M-code is:
let Source = Sql.Database("vm1", "TutorialDB", [Query="select *#(lf)from Customers#(lf)WHERE [customerid]=2#(lf)"]) in SourceNow, if you want to pass parameters to the where clause as Parameter1, (e.g. Parameter1 =2) make sure they are text first.
You can create a custom query as follows:
let Source = Sql.Database("x", "y", [Query="select *#(lf)from z#(lf)WHERE [customerid]="&Parameter1&"#(lf)"]) in SourceIf you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi powerbidev123 ,
Thanks for the reply from girishthimmaiah .
Assuming that your
Server = X
Database = Y
Table name = Z
The sample SQL query is (as if you put it on SSMS)
select *
from z
WHERE [customerid]=2
The conversion to M-code is:
let
Source = Sql.Database("vm1", "TutorialDB", [Query="select *#(lf)from Customers#(lf)WHERE [customerid]=2#(lf)"])
in
Source
Now, if you want to pass parameters to the where clause as Parameter1, (e.g. Parameter1 =2) make sure they are text first.
You can create a custom query as follows:
let
Source = Sql.Database("x", "y", [Query="select *#(lf)from z#(lf)WHERE [customerid]="&Parameter1&"#(lf)"])
in
Source
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!