Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jarednigel07
New Member

SQL Statement Error - SQL Server Database (Import)

 

 

I'm working on a different SQL Statement since I'm trying to load a table using an SQL Statement where the source is an SQL Server Database. So the steps are:

 

SQL Error.PNG

After clicking on OK:

SQL Error2.PNG

 

Here is the script:

 

SELECT [Active All Policies].[Counted as a Sale],
IFF (([Active All Policies].[Policy Type]='RN' & [Active All Policies].[Start Date]<TODAY() & [Active All Policies].[Counted as a Sale]='False'), "Yes",
IFF (([Active All Policies].[Policy Type]='NB' & [Active All Policies].[Start Date]<TODAY()-14 & [Active All Policies].[Counted as a Sale]='False'), "Yes", "No"))
AS Overdue,
[Active All Policies].[Risk Type], [Active All Policies].[Rating Answer 4], [Active All Policies].[Start Date], [Active All Policies].[Promotion ID],
[Active All Policies].[Signed Proposal Received], [Active All Policies].[Total Premium]
FROM [Active All Policies]
WHERE ([Active All Policies].[Total Premium]-[Active All Policies].[Total Paid]+[Active All Policies].[Write On or Off Amount]<>0 AND ([Active All Policies].[Payment Process]<>'Instalment' And [Active All Policies].[Payment Process]<>'Lump Sum via Broker') AND ([Active All Policies].[Risk Type]='Motor Vehicle' OR [Active All Policies].[Risk Type]='Payment Protection') AND [Active All Policies].[Total Premium]<>0) OR([Active All Policies].[Counted as a Sale]='False' AND ([Active All Policies].[Risk Type]='Motor Vehicle' OR [Active All Policies].[Risk Type]='Payment Protection') AND [Active All Policies].[Start Date]<=TODAY() AND [Active All Policies].[Total Premium]<>0)
ORDER BY [Active All Policies].[Counted as a Sale], [Active All Policies].[Total Premium]-[Active All Policies].[Total Paid]

 

Any can point out what I did wrong? Thanks in advance

1 ACCEPTED SOLUTION

Hi @jarednigel07,

Please change the "Yes", "No" to 'Yes','No' , we should use single quotation marks(' ') instead of double quotation marks (" "). Please test your SQL statement in SQL Server Management studio(SSMS) and confirm it works fine. Then past it to Get data navigator, to check if the error disppears.

Best Regards,
Angelia

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @jarednigel07,

 

As far as I know there is no IFF function in SQL Server (IIF is perhaps what you wanted to use).

 

Cheers,
Pawel

Thanks for pointing that out @Anonymous. I have changed it already but still getting the same error. 

Hi @jarednigel07,

Have you resolved your issue? If you have, please mark the right reply as answer, so more people will benefit from it.

Best Regards,
Angelia

Hi @jarednigel07,

Please change the "Yes", "No" to 'Yes','No' , we should use single quotation marks(' ') instead of double quotation marks (" "). Please test your SQL statement in SQL Server Management studio(SSMS) and confirm it works fine. Then past it to Get data navigator, to check if the error disppears.

Best Regards,
Angelia

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.