Join Martin Guidry for an in-depth discussion in this video Getting return values, part of SQL Server: Triggers, Stored Procedures, and Functions.
I mentioned earlier to you a recommendation that as a best practice;…every stored procedure return a value indicating success or failure.…Typically, we return a 0 for failure and the 1 for success.…We haven't yet implemented that.…So let's go ahead and work on it.…I'll change this code that creates a stored procedure into a code that alters…a stored procedure.…The last allow will be RETURN 1 for success.…We also need to define some failure condition.…As a hypothetical, we're going to say that if the first name is too short,…let's say extremely short, less than two characters, we'll define that as…a failure condition.…
Check for the if len(@FirstName).…If it's less than 2 characters, that is now defined as a failure condition.…So we'll need to RETURN a 0 to indicate this stored procedure was unsuccessful.…And as soon as it hits that line of RETURN 0, it will not execute the bottom.…It will not do the insert.…Command(s) completed successfully. That's good news.…Now we need to go over to our website and do a little more work.…
- Comparing triggers, functions, and stored procedures
- Installing and configuring SQL Server
- Creating a stored procedure
- Returning data using data sets
- Creating user-defined functions
- Using "after," "instead," and nested triggers
- Modifying existing stored procedures
- Implementing logging on DELETE
- Choosing between T-SQL and CLR
- Executing a stored procedure
- Passing parameters
Skill Level Advanced
1. Getting Started
2. Installing SQL Server
Configuring your environment4m 53s
3. Stored Procedures
4. User-Defined Functions
6. Putting It All Together
7. Using CLR Assemblies
8. Exploring an ASP.NET Web Application
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.