第1个回答 2016-01-06
例子:
master.dbo.xp_cmdshell 'osql -E -i d:\1.sql'
把d:\1.sql换成自己的sql文件路径
如果不使用可信任连接的话,就把-E换成 -U username -P thepassword
其他的就不写了,看下面的参数表自己琢磨。
其他东西
用法: osql [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w columnwidth]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-L list servers] [-c cmdend] [-D ODBC DSN name]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-n remove numbering] [-m errorlevel]
[-r msgs to stderr] [-V severitylevel]
[-i inputfile] [-o outputfile]
[-p print statistics] [-b On error batch abort]
[-O use Old ISQL behavior disables the following]本回答被网友采纳