Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#88 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
sql
Domain
compilers

Research direction

Use the supplied CREATE EXTERNAL TABLE statement with filepath() and filename() as the reproduction case, and first run it through the ScriptDOM parser to confirm where the syntax error is reported. Inspect the parser and grammar support for calculated columns in external tables, then add regression coverage showing that the valid SQL parses successfully.

Written by the indexing model from the issue text.

Description

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 !

Dominant language
GAP
Stars
277
Forks
43
Avg merge
6d 17h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/SqlScriptDOM

All issues in microsoft/SqlScriptDOM

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.