Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Split File into ChunksDemonstrates how to split a file into chunks.
// Important: See this note about string length limitations for strings returned by sp_OAMethod calls. // CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @fac int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.FileAccess', @fac OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Any type of file may be split. It doesn't matter if it's -- a binary file or a text file. DECLARE @fileToSplit nvarchar(4000) SELECT @fileToSplit = 'qa_data/hamlet.xml' DECLARE @partPrefix nvarchar(4000) SELECT @partPrefix = 'hamlet' DECLARE @partExtension nvarchar(4000) SELECT @partExtension = 'part' DECLARE @maxChunkSize int SELECT @maxChunkSize = 50000 DECLARE @destDirPath nvarchar(4000) SELECT @destDirPath = 'qa_output' -- Splits hamlet.xml into hamlet1.part, hamlet2.part, ... -- Output files are written to the current working directory. -- Each chunk will be 50000 bytes except for the last which -- will be the remainder. DECLARE @success int EXEC sp_OAMethod @fac, 'SplitFile', @success OUT, @fileToSplit, @partPrefix, @partExtension, @maxChunkSize, @destDirPath IF @success = 1 BEGIN PRINT 'Success.' END ELSE BEGIN EXEC sp_OAGetProperty @fac, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 END EXEC @hr = sp_OADestroy @fac END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.