first, you need to set credentials for the proxy account:sp_xp_cmdshell_proxy_account 'Username', 'Pa$$w0rd'
(this account has to exist on the machine)Then you need to enable xp_cmd_shell:-- To allow advanced options to be changed.EXEC sp_configure 'show advanced options', 1GO-- To update the currently configured value for advanced options.RECONFIGUREGO-- To enable the feature.EXEC sp_configure 'xp_cmdshell', 1GO-- To update the currently configured value for this feature.RECONFIGUREGO
see http://msdn.microsoft.com/en-us/library/ms190693.aspx for more details.
SELECT TOP 1 w.[name]FROM dbo.women wINNER JOIN dbo.inlaws i ON i.inlaw_id = w.parent_idWHERE i.net_worth > 10000000 AND i.status IN ('dead', 'dying') AND w.husband_id IS NULLORDER BY w.hotness_factor DESC