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! Get ahead of the game and start preparing now! Learn more
I am not able to define the @DateFrom and @ DateTo parameters in this OPENQUERY that I am using as my connection to SQL Server:
SELECT *
FROM OPENQUERY ([HostName],
'EXEC databasename.dbo.stored_procedure_name
@DateFrom = CONVERT(DATETIME, ''2024-04-25''),
@DateTo = GETDATE(),
@Client_Id = NULL,
@ClientStatus = ''ACT'',
@InsurancePlan = ''1'',
@InsurancePlanStatus = ''ALL''');
I get this error: "Microsoft SQL: Statement(s) could not be prepared.
Incorrect syntax near the keyword 'CONVERT'."
Can someone please suggest the correct syntax for the @DateFrom and @DateTo parms?
Solved! Go to Solution.
@FarmerKenny , Try like , if the database is SQL Server, Azure SQL or the one uses T-SQL
SELECT *
FROM OPENQUERY ([HostName],
'EXEC databasename.dbo.stored_procedure_name
@DateFrom = CONVERT(DATETIME2(6), ''2024-04-25''),
@DateTo = CONVERT(DATETIME2(6),GETDATE() ),
@Client_Id = NULL,
@ClientStatus = ''ACT'',
@InsurancePlan = ''1'',
@InsurancePlanStatus = ''ALL''');
@FarmerKenny , Try like , if the database is SQL Server, Azure SQL or the one uses T-SQL
SELECT *
FROM OPENQUERY ([HostName],
'EXEC databasename.dbo.stored_procedure_name
@DateFrom = CONVERT(DATETIME2(6), ''2024-04-25''),
@DateTo = CONVERT(DATETIME2(6),GETDATE() ),
@Client_Id = NULL,
@ClientStatus = ''ACT'',
@InsurancePlan = ''1'',
@InsurancePlanStatus = ''ALL''');
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |