Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Stravan
Contributor III
Contributor III

How to convert this sql into script in Qliview desctop

Hi,

I need help converting the following sql to regular script in QV. I have an ODBC connection to the database.

Thanks in advance

 

SELECT [t0].[Id], [t0].[AccNumber], [t0].[IsU], DATEPART(year, [t0].[AccDateTotal]) as Year,  (SELECT STUFF((SELECT ',' + CAST(PlaceAttributeId as varchar) FROM [st].[AccPlaceAttribute] WHERE Id = [t0].[Id] AND ValueSource = 3 FOR XML PATH('')) ,1,1,'')) AS PlaceAttribute

FROM (

    SELECT DISTINCT [a].[Id], [a].[AccDateTotal], [a].[AccNumber], [a].[BoatAccId], [a].[IsU]

    FROM [st].[Acc] AS [a]

    INNER JOIN (

                         (SELECT [a].[Id] AS [AccId]

                                     FROM [st].[Acc] AS [a]

                                     WHERE ((((EXISTS (

                                                  SELECT 1

                                                  FROM [st].[Report] AS [r]

                                                  WHERE ([a].[Id] = [r].[AccId]) AND (([r].[State] = 4) AND (([r].[AccDate] >= '2017-01-01') AND ([r].[AccDate] <= '2017-03-31')))))

                                                   AND [a].[BoatAccId] IS NULL) AND ([a].[Id] <> 0))

    ))) AS [t] ON [a].[Id] = [t].[AccId]

    WHERE [a].[IsU] = CAST(0 AS bit)

) AS [t0]

ORDER BY [t0].[AccNumber], [t0].[Id]

Labels (2)
1 Solution

Accepted Solutions
edwin
Master II
Master II

Have you tried adding this into your script?  QV is supposed to be able to send your SQL script as it is to the SQL - based database server through your connection (ODBC in your case).  you dont need to translate the script to a QV script.

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

or are you experiencing an error when you add this to your script?

View solution in original post

2 Replies
edwin
Master II
Master II

Have you tried adding this into your script?  QV is supposed to be able to send your SQL script as it is to the SQL - based database server through your connection (ODBC in your case).  you dont need to translate the script to a QV script.

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

or are you experiencing an error when you add this to your script?

Stravan
Contributor III
Contributor III
Author

Thank you Edwin, 

It went very well with running it directly in Qliview script. I should have tested it before I asked, sorry about that.