This can be done with an "it works, but isn't a particularly great thing to do" approach. It relies heavily on SQL Server technology.
- Create a stored procedure in SQL Server that takes an input parameter of <name of table>. Essentially, all this sucker will do is SELECT * from <name of table> using an IF statement or something.
On the SQL Server, create a "Linked Server" which points to itself. Mine is called "localhost":
EXEC master.dbo.sp_addlinkedserver @server = N'LOCALHOST', @srvproduct=N'SQL Server'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'LOCALHOST',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
- In Tableau, use Custom SQL to leverage SQL Server's OPENQUERY command to execute the stored procedure and pass in the <table name>:
SELECT * FROM OPENQUERY(LOCALHOST,'exec Catcher.dbo.Test t1 ') //or t2, or t3....
You'll need to play around a bit with single and double quotes (or combinations of same) in order to be able to switch out the table name dynamically using Tableau's new parameterized Custom SQL:
Your Custom SQL will probably look something like this:
SELECT * FROM OPENQUERY(LOCALHOST,<Parameters.SecretSauce>)
...and your parameters (in Tableau) will look like this:
exec Catcher.dbo.Test t1
exec Catcher.dbo.Test t2
exec Catcher.dbo.Test t3