microsoft / SqlScriptDOM

ScriptDOM/SqlDOM is a .NET library for parsing T-SQL statements and interacting with its abstract syntax tree
MIT License
128 stars 13 forks source link

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

Open jashwood opened 3 weeks ago

jashwood commented 3 weeks ago

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 !

curiousfurious commented 3 weeks ago

I have encountered the same issue. I can't build the project file in VS 2022 with this error.