Sunday 8 May 2022

sp_OACreate sp_OAMethod

DOC i FOLLOWED

https://tidbytez.com/tag/sp_oamethod/


OLE means: Object Linking and Embedding

Below sp_configure is used to use OLE procedures


--AUTHORIZE SYSTEM STORED PROCEDURES

sp_configure 'show advanced options' ,1;

GO

RECONFIGURE;

GO

sp_configure 'Ole Automation Procedures' ,1;

GO

RECONFIGURE;

GO

--AUTHORIZED


Use OLE stored procedures as below.

	DECLARE @OLE INT
	DECLARE @FileID INT

	EXECUTE sp_OACreate 'Scripting.FileSystemObject'
		,@OLE OUT

	EXECUTE sp_OAMethod @OLE
		,'OpenTextFile'
		,@FileID OUT
		,@File
		,8
		,1


MS DOC

https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/ole-automation-stored-procedures-transact-sql?view=sql-server-ver15

sp_OACreate: creates an instance of an OLE object

MS Doc shows format as below:

sp_OACreate { progid | clsid } , objecttoken OUTPUT [ , context ]


progid: identifier of OLE object to create, eg, 'Scripting.FileSystemObject'

objecttoken: is the returned object token. Must be INT type.

OUT means OUTPUT. https://www.sqlservercentral.com/forums/topic/stored-procedures-output-vs-out

https://stackoverflow.com/questions/4116912/what-are-in-and-out-parameter-in-sql-server







No comments:

Post a Comment