In Tableau, I'm trying to add a column through Alter Table
in a custom SQL
It looks like this:
ALTER TABLE (SELECT [W$].[W], [W$].[SDate], [W$].[EDate], [Date E$].[Date]
FROM [W$],[Date E$]
WHERE [Date E$].[Date]
BETWEEN [W$].[SDate] AND [W$].[EDate])
ADD [Type] string NOT NULL DEFAULT "P1"
But I get an error saying Syntax Error in FROM clause
.
I also get this error if I use ALTER TABLE [Date E$]
ALTER TABLE [Date E$]
ADD [Type] string NOT NULL DEFAULT "P1"
error message:
Database error 0x80040E14: Syntax error in FROM clause.
; The query: SELECT TOP 1 * FROM ( ALTER TABLE [Date E$]
ADD [Type] string NOT NULL DEFAULT "P1" ) [TableauSQL]
This is my first time using Alter Table so I'm not sure where the FROM clause is being used, or if I'm doing this incorrectly. I'm following the instructions I found here: Add a column with a default value to an existing table in SQL Server
Is it possible that Tableau doesn't allow Alter Table to be used when creating a Custom SQL?
I am using Tableau Desktop 2018.1.2
Tableau custom SQL will not allow DDL statements such as Alter table. It creates a read-only connection to the database. You might be able to do this using the initial sql function that is available when you setup your connection. Really Tableau is the wrong tool for this. If you want to alter tables you should use a SQL client thats appropriate for your database.