-
Notifications
You must be signed in to change notification settings - Fork 714
Best way to execute this script #216
-
Hi,
I'm a newbie on sql server. What would be the best way to execute this script in order all results save to a file?
I mean, in Oracle we can put ---> spool filename.lst, then execute the statements, and then: spool off and all the results are on that file.
Have SQL Server has similar way?
thank you
Beta Was this translation helpful? Give feedback.
All reactions
Yes, it is. You can use default sqlcmd utility https://stackoverflow.com/a/425463/2298061
But but I highly recommend mastering a great powershell module https://docs.dbatools.io/Export-DbaXECsv.html
Replies: 2 comments 3 replies
-
Yes, it is. You can use default sqlcmd utility https://stackoverflow.com/a/425463/2298061
But but I highly recommend mastering a great powershell module https://docs.dbatools.io/Export-DbaXECsv.html
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Thank you for your response, it will be great when I execute one statement.
Let me explain. I want to execute all this sql script once and the result of all statements save on a txt file.
How can I do that?
thanks in advanced
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for your response, it will be great when I execute one statement. Let me explain. I want to execute all this sql script once and the result of all statements save on a txt file. How can I do that? thanks in advanced
could you provide your script and desire result?
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi,
the script is
-- SQL Server 2008 R2 Diagnostic Information Queries
-- Glenn Berry
SQLServer2008HealthCheck_v01.txt
I will execute this on MSSQL server 2008
regards,
Beta Was this translation helpful? Give feedback.
All reactions
-
Invoke-DbaDiagnosticQuery -SqlInstance sql2016 -UseSelectionHelper | Export-DbaDiagnosticQuery -Path C:\temp\gboutput
I strongly recommend spending 2 hours of your time to master the magnificent dbatools package - it will be the best investment in your developer career!
Beta Was this translation helpful? Give feedback.