(SQL Server) Get the Target of a Symbolic Link
Demonstrates how to get the target of a symbolic link.
Note: This example requires Chilkat v9.5.0.77 or greater.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @fac int
-- Use "Chilkat_9_5_0.FileAccess" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.FileAccess', @fac OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @targetPath nvarchar(4000)
EXEC sp_OAMethod @fac, 'SymlinkTarget', @targetPath OUT, 'qa_data/my_symlink'
EXEC sp_OAGetProperty @fac, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 <> 1
BEGIN
PRINT 'Failed to get symlink target.'
EXEC @hr = sp_OADestroy @fac
RETURN
END
PRINT 'target path = ' + @targetPath
EXEC @hr = sp_OADestroy @fac
END
GO
|