Sample code for 30+ languages & platforms
SQL Server

Get the Target of a Symbolic Link

See more FileAccess Examples

Demonstrates how to get the target of a symbolic link.

Note: This example requires Chilkat v9.5.0.77 or greater.

Chilkat SQL Server Downloads

SQL Server
-- 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
    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