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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.