开发者

Can I use TSQL to operate on normal os files? Such as create a .bat file and write some query result into that file?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜