
Outline sql server programming and stored procedures, covering parameters, variables, output parameters, if statements, while loops, temporary tables, table variables, common table expressions, dynamic sql, transactions, and triggers.
Add a parameter to a stored procedure by listing parameters in parentheses after the name, with each parameter beginning with @ and declaring @list_price as int.
Learn how to make stored procedure parameters optional, avoiding the need to pass values for all three parameters on every execution.
Learn to give default values to parameters in stored procedures, making them optional, update the procedure, and test by omitting the parameter to use zero for the minimum list price.
Learn to use variables in SQL Server: declare, assign, and reference them in queries, display with print or select, and access global variables for system information.
Learn to declare variables in SQL Server, placing the @variable at the top of a procedure, naming it, and assigning the date time data type.
Learn to assign a value to a variable in SQL Server using set, matching the value to the declared data type. Emphasizes syntax, variable naming, and data type compatibility.
Demonstrate printing variable values in SQL Server Management Studio's messages tab using print, converting to text with cast or convert, and concatenating with plus for clear sentences.
Learn to set output parameters in a stored procedure, computing the row count and building a comma-separated product list with a declared variable, then assign and save.
Learn to use the else clause in SQL Server stored procedures by adding an else branch to an if statement. Handle conditions and customize messages when thresholds are not met.
Demonstrates the basic syntax of a while loop in SQL Server, initializing a counter at one, looping while it is less than or equal to 15, printing and incrementing.
Explore scalar functions in SQL Server, inspect built-in date name function details in object explorer, and learn to create a custom function that encapsulates date formatting logic.
Explore temporary tables in SQL Server, including definitions, two creation methods, appending records, scope and global temporary tables, and how to remove them.
Understand the life cycle of table variables and their persistence versus temporary tables. See how table variables persist during code execution and why explicit drop statements matter.
Learn SQL Server Programming by doing!
This course will assist you in achieving the objective of creating useful and powerful stored procedures. This is a step-by-step course. We will build on what we had learned in every new session. This course teaches you SQL Programming and Stored Procedure from scratch. No prior programming experience is required.
Why should you learn SQL even if you are not a Developer?
These days, almost everyone has to work with data in some form or another. Usually, it's through spreadsheets or databases, but if you can learn a little SQL you can become so much more powerful in your job.
Who is teaching you?
My name is Enrique Valencia. I’m a database professional based in Singapore. I’ve been a SQL Server DBA for 7 years. Now, I’m working on various open-source databases such as MySQL, MariaDB, PostgreSQL, Redis, Elasticsearch, and MongoDB. My focus is on SQL performance optimization, high availability, and automation.
I hope that you’ll enjoy this course as much as I did creating it!
Below is the list of topics that will be covered in this course.
Stored Procedure Fundamentals - A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again.
Using Parameters in Stored Procedures - used to exchange data between stored procedures and functions and the application or tool that is called the stored procedure or function.
Variables - an object that can hold a single data value of a specific type.
Output Parameters & Return Values - two ways of returning result sets or data from a Stored Procedure to a calling program.
IF Statements - Imposes conditions on the execution of a Transact-SQL statement.
WHILE Loops - used to repeatedly execute a certain piece of SQL script.
User Defined Functions - routines that accept parameters, perform an action, such as a complex calculation, and return the result of that action as a value.
Temporary Tables - database table that exists temporarily on the database server.
Table Variables - a special type of the local variable that helps to store data temporarily, similar to the temp table in SQL Server.
Table Valued Functions - user-defined function that returns a table data type and also it can accept parameters.
Common Table Expressions (CTEs) – a temporary named result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement.
Dynamic SQL Scripts - a programming technique that enables you to build SQL statements dynamically at runtime.
Transactions - a sequential group of statements or queries to perform single or multiple tasks in a database.
DML Triggers - a special type of stored procedure that automatically takes effect when a data manipulation language (DML) event takes place that affects the table or view defined in the trigger.
DDL Triggers - fire in response to a variety of Data Definition Language (DDL) events.