Thursday, June 25, 2015

Temp Tables in Tableau Error

Temp Tables in Tableau


Assume a Stored Procedure in SQL server using some Temp Tables and return a result set from that Temp Table like below:

CREATE PROC Tableau_Temp
AS
BEGIN

SELECT * INTO #Temp_Sales FROM Sales.SalesOrderDetail

SELECT * FROM #Temp_Sales


END

Once you add Stored Procedure in Tableau then you will get below error.




The reason for this error is, Tableau always return the first result set from Stored Procedure. In the case above it would be “123456 rows affected” see in message tab. So avoid these such type of messages in SP and apply “SET NOCOUNT ON” as below:

ALTER PROC Tableau_Temp
AS
BEGIN

SET NOCOUNT ON

SELECT * INTO #Temp_Sales FROM Sales.SalesOrderDetail

SELECT * FROM #Temp_Sales


END


Once you have done this change then you will get desire output as below:

So use SET NOCOUNT ON