Can I use TSQL to operate on normal operating system files? Such as create a .bat file at c:\开发者_StackOverflow社区test and write some query result into that batch file?
Thanks.
For general tips on reading/writing files, you can check out this link.
You can also use SQLCMD
, like this (input.sql would be your input sql, Results.txt would be your output):
SQLCMD -i Input.sql -o C:\Results.txt -e
Yes use SQLCMD
You could also use xp_cmdshell:
xp_cmdshell
Executes a given command string as an operating-system command shell and returns any output as rows of text. Grants nonadministrative users permissions to execute xp_cmdshell.
link to: xp_cmdshell - msdn reference
精彩评论