Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想每周运行一次 dbcc checkdb,并希望将结果存储在 .txt 文件中。请让我知道如何将数据从 ssms 导出到 txt 文件。
提前致谢!!
您可以将脚本保存到 .sql 文件中并使用sqlcmd实用程序执行它。
例如:exec xp_cmdshell 'SQLCMD -i "D:\ChdbQuery.sql" -o "D:\dbcheckpubs.txt"'
exec xp_cmdshell 'SQLCMD -i "D:\ChdbQuery.sql" -o "D:\dbcheckpubs.txt"'
只需要适当地更改路径、服务器名称和身份验证