I can seem to find an answer to this even on Microsoft sites I am using this:
EXECUTE @RetCode = sp_OAMethod @FileSystem,
'OpenTextFile',
@FileHandle OUTPUT,
@FilePath,
8,
1
I would like to know what the finale int parameter (1) does and what other options there are for this. I experimented and used 2 but did not see any difference.
I know that the second last int parameter (8) specifies an append vs using 2 a write but do not know of other values for this parameter either.
The sp_OAMethod is executing method of the given object, in this case is a FileSystemObject OpenTextFile has 4 parameters in this order:
- FilePath -Required. The name of the file to open
- Mode - Optional. How to open the file
- 1 = Reading - Open a file for reading. You cannot write to this file.
- 2 = Writing - Open a file for writing.
- 8 = Appending - Open a file and write to the end of the file.
- Create - Optional. Sets whether a new file can be created if the filename does not exist. True indicates that a new file can be created, and False indicates that a new file will not be created. False is default.
- Format - Optional. The format of the file
- 0 = TristateFalse - Open the file as ASCII. This is default.
- 1 = TristateTrue - Open the file as Unicode.
- 2 = TristateUseDefault - Open the file using the system default.
In your case (8) is the Mode
, and (1) is the Create
.
You can read more about it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With