DECLARE @DataPath nvarchar( 512 ) , @SQLPath nvarchar( 512 ) ,
        @ToolsPath nvarchar( 512 ) , @CmdStr nvarchar( 4000 );
EXECUTE dbo.sp_MSgettools_path @ToolsPath OUT;
EXECUTE sp_MSget_setup_paths @SQLPath OUT , @DataPath OUT;
PRINT 'SQLPath   : ' + QUOTENAME( @SQLPath , '"');
PRINT 'DataPath  : ' + QUOTENAME( @DataPath , '"');
PRINT 'ToolsPath : ' + QUOTENAME( @ToolsPath , '"');
SET @CmdStr = QUOTENAME( @ToolsPath + '\BINN\OSQL', '"') + ' -L'
PRINT 'CMDStr    : ' + @CmdStr
EXECUTE master..xp_cmdshell @CmdStr
GO