--打开Ad Hoc Distributed Queries
exec sp_configure ''show advanced options'',1
reconfigure
exec sp_configure ''Ad Hoc Distributed Queries'',1
reconfigureGO
insert  INTO
 OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'c:\A.mdb'; 'admin'; '', 表A)
select '1'
GO上面这样的话就要求我C:\A.mdb 和 表A 必须先有的
如何没有的时候他们会自动创建呢谢谢

解决方案 »

  1.   

    -- To allow advanced options to be changed.
    EXEC sp_configure 'show advanced options', 1
    GO
    -- To update the currently configured value for advanced options.
    RECONFIGURE
    GO
    -- To enable the feature.
    EXEC sp_configure 'xp_cmdshell', 1
    GO
    -- To update the currently configured value for this feature.
    RECONFIGURE
    GOexec   master..xp_cmdshell   'bcp   "select   *   from   sysobjects"   queryout   d:\a.mdb   -c   -q   -Usa   -Ppwd'