Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Best way to execute this script #216

Answered by ktaranov
cesarhijarsm asked this question in Q&A
Discussion options

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

You must be logged in to vote

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

Comment options

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

You must be logged in to vote
2 replies
Comment options

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

Comment options

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?

Answer selected by ktaranov
Comment options

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,

You must be logged in to vote
1 reply
Comment options

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /