Enter the following code in the query window, then click "SQLCMD Mode" to open "SQLCMD mode"
: OUT C: /TEST.TXT - Output path Select @@ version as 'server version' ---- SQL version !! DIR !!: gosect @@ servername as 'server name' - server name Gouse ExampleGosent * from SprodclsSGO
operation result:
Create a Test.txt file under the C drive