SqlScriptDOM
SqlScriptDOM copied to clipboard
CREATE EXTERNAL TABLE with filepath() or filename() calculated column gives syntax error
CREATE EXTERNAL TABLE [stg].[my_table] ( [COLUMN_ONE] VARCHAR (50) NULL, [filepath] AS CAST(filepath() AS NVARCHAR(1024)), [filename] AS CAST(filename() AS NVARCHAR(1024)) ) WITH ( DATA_SOURCE = [DataSource1], LOCATION = N'somepath/somefile*.csv', FILE_FORMAT = [TildeDelimitedQuoted_CSV], REJECT_TYPE = VALUE, REJECT_VALUE = 0 );
The above is valid and runs in SQL Managed Instance but in VS 2022 with latest updates I get Incorrect Syntax near 'AS'
This is a problem for us and we are having to revert to using views with OPENQUERY rather than external tables as we need the filepath and filename in the external table resultset. I hope this is the right place to raise this !