Comments (5)
@dantheother yup! It's awesome, that's probably my number 1 use for it. Every stored procedure I write is packed with them.
Messages get pushed to a buffer, but the buffer only occasionally gets flushed to output, and using NOWAIT will force a flush. I cover this at the top with a couple examples including substitution parameters to add a log date.
from chadbaldwin.github.io.
@dantheother I decided to add in a demo specifically for this, as it really is one of my favorite uses and should be included in this post. Thanks for the comment!
from chadbaldwin.github.io.
Another cool feature of RAISERROR is you can capture the output from calling code if you're using an sqlConnection object. Here's an example in c# https://stackoverflow.com/a/23774727/11569, there's powershell examples out there too. Great way of getting messages to the console/ui (I guess console is a UI) for really long running stored procedures. Or for logging extra info about stored procedure executin.
from chadbaldwin.github.io.
RAISERROR WITH NOWAIT runs into buffering problems too (but later than the usual PRINT).
See my question / demo at https://dba.stackexchange.com/questions/270729/ssms-sql-server-delays-console-output-raiseerror-with-nowait
Print starts to buffer after 40 lines, RAISERROR starts after 500 lines to buffer 50 lines.
So even RAISERROR is not the perfect solution for loops or much speaking stuff (imaging the use of Ola Hallengren's Maintenance procedures when you run eg. Index optimize over 100 databases with tons of tables each)
from chadbaldwin.github.io.
@samot1 Yup, I run into this limit all the time, but didn't feel the need to get into that level of detail as the 500 message cutoff, then switch to every 50 is sufficient for the majority of people. A few sections of this post probably could have been blog posts of their own, heh. The main goal is to encourage developers to improve the output on their code to aide readability and monitoring progress, there will always be outliers.
This is also the reason I recommended the interval option by only outputting messages in intervals rather than for every iteration of the loop.
That's a nice demo btw, I like that.
from chadbaldwin.github.io.
Related Issues (19)
- [Comments] Only update rows that changed? Try using EXISTS and EXCEPT HOT 2
- [Comments] Clean up your queries and simplify logic with CROSS APPLY HOT 3
- [Comments] SSMS Keyboard Query Shortcuts HOT 6
- [Comments] Certifications and learning HOT 5
- [Comments] Use merge to split data into multiple tables
- [Comments] "There's no way that will run"
- [Comments] Building a Free Blog with GitHub Pages in Minutes HOT 105
- [Comments] Quick post - Parsing a pipe delimited file to get a unique list of values
- [Comments] Quick Post - Building diagrams using graphviz HOT 3
- [Comments] THROW command is non-terminating across linked servers HOT 2
- [Comments] Bookmarks
- [Comments] PowerShell Common Parameters: PipelineVariable
- [Comments] Your public "private" info and how to remove (most) of it
- Copy a large table between servers, a couple wrong ways, maybe one right way HOT 5
- Working with secure FTP in PowerShell HOT 3
- Whatβs new in SQL Server 2022 HOT 6
- Restore database from backup in Docker HOT 1
- Blog Post Title From First Header HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chadbaldwin.github.io.