
Answer-first summary for fast verification
Answer: the WITH clause
## Explanation To solve this requirement of assigning column names and overriding inferred data types when reading TSV files using the OPENROWSET function, the correct approach is to use the WITH clause. ### Why Option A (WITH clause) is correct: The WITH clause in OPENROWSET allows explicit schema definition, which directly addresses both requirements: 1. **Assign column names**: When TSV files lack headers, the WITH clause enables you to specify meaningful column names instead of relying on generic names like C1, C2, etc. 2. **Override inferred data types**: The WITH clause allows you to explicitly define the data type for each column, overriding the automatic type inference that OPENROWSET performs by default. **Example syntax**: ```sql SELECT * FROM OPENROWSET( BULK 'https://storageaccount.blob.core.windows.net/container/files.tsv', FORMAT = 'CSV', PARSER_VERSION = '2.0', FIELDTERMINATOR = '\t' ) WITH ( CustomerID INT, CustomerName VARCHAR(100), OrderDate DATE, TotalAmount DECIMAL(10,2) ) AS result; ``` ### Why other options are incorrect: **Option B (ROWSET_OPTIONS bulk option)**: This parameter controls data processing behaviors like buffering and parallelism, but does not handle column naming or data type specification. **Option C (DATAFILETYPE bulk option)**: This option specifies file encoding (UTF-8, UTF-16) but does not address column naming or data type overriding requirements. **Option D (DATA_SOURCE parameter)**: While DATA_SOURCE can be used to reference external data sources, it does not provide functionality for defining column names or overriding data types. Additionally, since the files are publicly accessible, DATA_SOURCE is not strictly required for authentication purposes. ### Key Considerations: - The WITH clause is specifically designed for schema definition in OPENROWSET queries - It provides full control over column metadata when files lack headers - It ensures data type consistency and prevents potential issues from automatic type inference - It's the standard Microsoft-recommended approach for explicit schema definition in serverless SQL pools
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You have an Azure subscription containing the resources listed in the table.
//IMG//
You need to query TSV files using ad-hoc queries with the OPENROWSET function. The solution must assign a column name and override the inferred data type for every column.
What should you include in the OPENROWSET function?

A
the WITH clause
B
the ROWSET_OPTIONS bulk option
C
the DATAFILETYPE bulk option
D
the DATA_SOURCE parameter
No comments yet.