GlobalTable_To_File
Serializes tabular data in a global temporary table into a file
- Stored Procedure
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
EXEC SQLHTTP.net.GlobalTable_To_File @GlobalTableName, @FilePath, @Delimiter, @FirstRowAsFieldNames
Name | Type | Description |
---|---|---|
@GlobalTableName | varchar(100) | Name of a Global Temporary Table that has been created and populated with data |
@FilePath | nvarchar(MAX) | Full path to a non-existing file |
@Delimiter | nvarchar(4000) | String, usually a single character such as a comma, to be used a row separator |
@FirstRowAsFieldNames | bit | 1 = The column names of the Global Temporary Table will be included as the first row. 0 = Only the Global Temporary Table data will be serialized. |
Accessing the file system will be performed in the context of the SQL Server instance process. You can set SQL Server to run using a specific network account, or a Local System Account.
This example demonstrates copying the content of a view (OLEDBProviders) into a global temporary table which is then serialized into a file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
DECLARE @GlobalTableName varchar(100) DECLARE @FilePath varchar(MAX) DECLARE @Delimiter nvarchar(4000) DECLARE @FirstRowAsFieldNames bit SELECT * INTO ##Temp FROM SQLHTTP.net.OLEDBProviders SET @GlobalTableName = '##Temp' SET @FilePath = 'C:\ThisFolderExists\OLEDBProviders.txt' SET @Delimiter = ',' SET @FirstRowAsFieldNames = 0 EXEC SQLHTTP.net.GlobalTable_To_File @GlobalTableName, @FilePath, @Delimiter, @FirstRowAsFieldNames |
1 2 3 |
Command(s) completed successfully. |
- CodePageEncodings
- FileCopy
- FileDecrypt
- FileDelete
- FileEncrypt
- FileMove
- FileRead
- Files_To_Table
- FileWrite
- FolderCopy
- FolderCreate
- FolderDelete
- FolderMove
- Folders_To_Table
- GlobalTable_To_File
- IsExistingFile
- IsExistingFolder
- TempPath
- ZipEntryAppend
- ZipEntryRemove
- ZipExtract_To_Folder
- ZipExtract_To_Table