How to get SQL from Tableau

Follow below steps:

select Help → Settings and Performance → Start Performance Recordingfrom the Tableau toolbar.

Then right click on the source in the Data toolbar and select ‘Refresh’. This will force Tableau to re-run the query.

Once the query completes, select Help → Settings and Performance → Stop Performance Recording from the Tableau toolbar.

This should result in a new Tableau window opening with a workbook called ‘Tableau — PerformanceRecording’

Right-click anywhere in the bar next to ‘Executing Query’ and select ‘View data’

Source of the article:
Below URL gives a very good idea about this