SqlScriptDOM icon indicating copy to clipboard operation
SqlScriptDOM copied to clipboard

CREATE EXTERNAL TABLE with filepath() or filename() calculated column gives syntax error

Open jashwood opened this issue 8 months ago • 1 comments

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 );

image image

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 !

jashwood avatar Jun 26 '24 01:06 jashwood