Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to Oracle external tables in SQL Server

Is there an equivalent to Oracle's External Table in SQL Server ?

An external table is a table which is mapped to a flat-file in the filesystem.

It is very convenient since it allows you to read a flat-file as a table with standard SQL.

like image 722
Bassal Avatar asked Feb 14 '13 14:02

Bassal


People also ask

Can we create external table in SQL Server?

In SQL Server, the CREATE EXTERNAL TABLE statement creates the path and folder if it doesn't already exist. You can then use INSERT INTO to export data from a local SQL Server table to the external data source. For more information, see PolyBase Queries.

What is external tables in SQL Server?

The external tables feature is a complement to existing SQL*Loader functionality. It enables you to access data in external sources as if it were in a table in the database.

What is external tables in Oracle SQL?

An external table is a table whose data come from flat files stored outside of the database. Oracle can parse any file format supported by the SQL*Loader.

What is external data source in SQL Server?

Overview: SQL Server 2016 Creates an external data source for PolyBase queries. External data sources are used to establish connectivity and support these primary use cases: Data virtualization and data load using PolyBase. Bulk load operations using BULK INSERT or OPENROWSET.


1 Answers

Harold Javier's answer is a good one,
but you might also want to consider using OPENROWSET with the BULK keyword.

It is different from the external table because you don't "create" a table but more of a query.

It should look something like this:

SELECT et.*
FROM OPENROWSET( BULK 'your_data_file', FORMATFILE = 'your_format_file.fmt') AS et

Instead of giving the format in the table definition (as in oracle), you should add a fmt file.
Here is how to create it

like image 188
A.B.Cade Avatar answered Oct 30 '22 14:10

A.B.Cade