Resolve hostnames with t-sql

后端 未结 2 1308
面向向阳花
面向向阳花 2020-12-22 04:07

How can i resolve a hostname in t-sql? a 2000 compatible method is preferred. Although something that works on 2005/2008 would also be helpful.

eg. If i have the

2条回答
  •  不思量自难忘°
    2020-12-22 05:01

    SQL Server may block access to procedure 'sys.xp_cmdshell' as part of the security configuration. As a system administrator you can enable the use of 'xp_cmdshell' as follows:

    -- Allow advanced options.
    EXEC sp_configure 'show advanced options', 1;
    GO
    -- Update the currently configured value for advanced options.
    RECONFIGURE;
    GO
    -- Then, enable the feature.
    EXEC sp_configure 'xp_cmdshell', 1;
    GO
    -- Update the currently configured value for this feature.
    RECONFIGURE;
    GO
    -- Then you can go ahead and run ...
    exec master..xp_cmdshell 'nslookup microsoft.com'
    GO
    

提交回复
热议问题