一次性执行一个语句并输出到文件: osql -Usa -dSCGWYDJ2012 -P -S192.168.56.1 -Q "exit( SELECT top 1 * FROM A08)" -o "C:UsersAdministratorDesktop extfile.txt"
列所有表: SELECT TABLE_NAME FROM SCGWYDJ2012.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
参考: https://docs.microsoft.com/en-us/sql/tools/osql-utility