Moving a File or Excel connection to a new location#
This guide shows how to point a File or Excel connection at the new location of its files, for example after
they moved from E:\data to \\files\data, so that every imported table keeps reading its data.
When Querona imports a file as a table, the table stores the absolute path of that file, or of its workbook for an Excel worksheet. Changing the connection’s location does not change those stored paths by itself. A File table keeps reading the old file and fails once that file is gone; an Excel worksheet fails as soon as its stored workbook is no longer under the connection’s location. A location change therefore does two things: it changes the connection, and it moves the stored paths of the tables to the new location, in one save.
Before you start#
You need the Alter connection access right on the connection (see Managing connections).
Write every location as an absolute path (
E:\data), a UNC path (\\files\data) or a URI. A relative path (.\data) or a barefile:location is refused when a save adds it, because its meaning would depend on the working directory of the Querona service.The built-in File tables (
builtin.AllFiles,builtin.TextFilesand the others in the builtin schema) read the connection’s current locations, so they follow the connection without being moved.
Recommended order#
Copy the data first. Copy the folder or the workbooks to the new location, and keep the old copy for now.
Change the connection as described below, and confirm where the tables move.
Check the result. Read a few of the moved tables, and review any warnings the save reported.
Remove the old copy when the moved tables read correctly.
You can also change the connection before the data is copied. The save goes ahead and reports, once, at the time of the save, that the new location is unreachable or that files are missing.
Change the location#
For a File connection:
Go to the section, select the connection and click EDIT.
Open Source URIs. Under each entry, the blade shows how many imported tables it covers.
Replace the old entry with the new location, or add the new location and remove the old one. Click OK.
Click SAVE.
For an Excel connection, change Server or data source name (the folder that holds the workbooks, or a single workbook), then click SAVE.
When the change would leave tables reading files outside the connection’s locations, the save stops and the Move tables to the new locations dialog opens. It lists one row per removed location:
Old location - the removed location the tables read from.
New location - where these tables move. When the dialog has one row and the save adds exactly one location, that location is filled in for you.
Tables - how many tables move. Click the number to list the tables you have access to; the others are only counted.
Check or enter the New location of every row, then click MOVE AND SAVE. The connection and all moved tables are saved together, in one step: either everything is saved or nothing is. CANCEL closes the dialog and keeps your edit unsaved.
ALTER EXTERNAL DATA SOURCE ... SET LOCATION replaces the first location of a File connection; it
does not accept an Excel connection. When
tables under the old first location would otherwise read outside the connection’s locations, the
statement moves them to the new location:
ALTER EXTERNAL DATA SOURCE MyFiles SET LOCATION = '\\files\data';
The statement reports the move as an informational message, for example:
Tables moved from 'E:\data' to '\\files\data': 12.
See ALTER EXTERNAL DATA SOURCE.
sp_updatelinkedserver @datasrc can change the location of a File or an Excel connection too, but it
never moves tables: a call that would leave tables outside the connection’s locations is refused. To
move them, use ALTER EXTERNAL DATA SOURCE for a File connection, or the Admin Portal for a File or
Excel connection. See
sp_updatelinkedserver.
How tables move#
A move is a pair of an old and a new location:
A folder moves every file below the old folder to the same relative path under the new folder. With the pair
E:\datato\\files\data, a table readingE:\data\sales\2024.csvreads\\files\data\sales\2024.csvafterwards. The new folder must be a local or UNC folder, not a URL, and its name must not end in the extension of a data file the connection reads (such as.csv).A file moves one file or workbook. The new location must be a file with the same extension.
Every moved path must be one of the connection’s locations after the save or lie inside one, so a move can never point a table outside the connection. Each old location can be moved once, a new location cannot lie inside another pair’s old location, and every pair must move at least one table. A table whose file the new locations still cover keeps its path and is not moved.
Changes that need no move#
A change that still covers every imported table is saved without a dialog and without moving anything. For example:
widening a location to its parent folder, such as
E:\data\2024toE:\data;adding a location;
removing a file entry while a folder entry that contains the file stays.
A location covers a table when the table’s stored file is that location or lies inside it:
A local or UNC folder covers the files inside it and inside its sub-folders. Letter case follows the operating system of the Querona host: it is ignored on Windows and significant on Linux.
A remote URL covers only a stored location with exactly the same text.
An Excel connection whose location is a single workbook covers only that workbook; a folder covers the workbooks inside it.
What is refused#
Every change of a File or Excel connection’s locations is checked the same way, whether it comes from the
Admin Portal, the management API, ALTER EXTERNAL DATA SOURCE or sp_updatelinkedserver. A change that
would leave imported tables reading files outside the connection’s locations, and that no move covers, is
refused as a whole, and nothing is saved:
The locations of connection 'MyFiles' cannot be changed: tables would read files outside the connection's locations. Keep the locations these tables use, or move the tables to the new locations.
Tables that still use the location 'E:\data': 5. Tables: [Sales].[dbo].[orders_csv], [Sales].[dbo].[customers_csv]. Of these, tables you have no access to: 3.
The message has one line per removed location. It names up to ten tables you have access to and only counts the tables you cannot access; their names and paths are never shown. The check itself covers every table on the connection, including tables in databases you cannot see.
Moving a database to another connection, by changing the connection of the database, is checked the same way. A move carries no pairs, so it is refused when the target connection’s locations do not cover the files the database’s tables read; a connection of another provider covers none of them. The message names the database and the target connection, followed by the same per-location lines:
Database 'Sales' cannot be moved to connection 'NewFiles': its tables would read files outside the locations of that connection.
Add the locations the tables read to the target connection first, or move the tables within their current connection before you move the database. A schema or table that names a connection of its own follows that connection and is not part of the check.
Warnings after the save#
After a save that moved tables, Querona checks the new locations. It does not refuse the save: a problem is reported as a warning, and the save stands. Typical warnings:
The location '\\files\data' does not exist or cannot be reached. Tables moved there: 12.The file '\\files\data\sales\2024.csv', which a moved table reads, does not exist.
A missing file is named only for a table you have access to; the files of other tables are counted. The check
probes at most 100 of the connection’s locations and 100 moved files, and counts the rest as not checked. The
Admin Portal shows the first five
warnings after its success message and counts the others in one more message. ALTER EXTERNAL DATA SOURCE
sends them as further informational messages.
If you changed the connection before copying the data, these warnings are expected. Copy the data, then read the tables.
Repairing tables already outside the locations#
Tables can already read files that none of the connection’s locations covers, for example when the location was changed before this check existed. Such tables do not block a save.
Bring the old location back, then remove it again. This works for File and Excel connections, and for tables you cannot see as well:
Bring the old location back: for a File connection, add it to the list next to the new one; for an Excel connection, which has one location, set it back. The save is accepted, because the tables read under it.
Remove the old location again, or for Excel set the new one again, as described in Change the location. The tables now read under a location the save removes, so they are moved: by the dialog in the Admin Portal, or for a File connection whose old location is the first entry, by
ALTER EXTERNAL DATA SOURCE.
ALTER EXTERNAL DATA SOURCE ... SET LOCATION on its own does nothing for these tables: it moves only tables
that read under the location it replaces.
Repair (File connections only, in the Admin Portal) moves such tables without changing the location twice:
Edit the connection and open Source URIs. The Tables outside the locations panel lists the tables you have access to that no entry covers.
Click Repair next to a table. The Move tables to the new locations dialog opens, with the folder of the table’s file as the Old location. You can edit it.
Enter the New location, which must be one of the connection’s entries or lie inside one, and click MOVE AND SAVE. The move is checked at once but not yet saved: it is listed under Moves applied when you save, where Delete drops it. The move applies to every table you have access to under the old location, not only to the one you clicked; tables you cannot see are not moved this way.
Click OK, then SAVE. The pending moves are applied with the save.
An Excel connection has no Source URIs blade, so it has no Repair; change its location back and again instead.
Note
Importing the tables again does not repair them. Import leaves a table whose columns did not change as it is, with its old path.
Auditing#
When auditing is enabled, a connection saved in the Admin Portal is recorded as an ALTER of an external data
source, with the text ALTER EXTERNAL DATA SOURCE [MyFiles] /* saved in the Admin Portal */, whether the save
succeeded or was refused. Each table the save moves, and each built-in table whose own copy of the location list
it drops, is recorded as an ALTER of that table, for example ALTER TABLE [Sales].[dbo].[orders_csv] /*
location moved by connection 'MyFiles': 'E:\data\orders.csv' -> '\\files\data\orders.csv' */. These texts
describe the change; they are not statements that Querona runs. ALTER EXTERNAL DATA SOURCE records the
statement itself and the same table events; sp_updatelinkedserver records no event.