Collections:
Creating Stored Procedures with Statement Blocks in SQL Server
How To Create a Stored Procedure with a Statement Block in SQL Server Transact-SQL?
✍: FYIcenter.com
If you are creating a stored procedure with multiple statements, it's better to use "BEGIN ... END" to group all statements into a single statement block.
The tutorial exercise below shows you some good examples:
USE FyiCenterData; GO CREATE PROCEDURE Show AS BEGIN SELECT name, type_desc FROM sys.tables; SELECT name, type_desc FROM sys.views; SELECT name, type_desc FROM sys.procedures; END; GO Command(s) completed successfully. EXEC Show; GO name type_desc ------------------- --------------------- fyi_random USER_TABLE fyi_links_indexed USER_TABLE fyi_links USER_TABLE fyi_links_copy USER_TABLE name type_desc ------------------- --------------------- fyi_links_top VIEW fyi_links_dump VIEW fyi_links_view VIEW name type_desc ------------------- --------------------- Hello SQL_STORED_PROCEDURE date SQL_STORED_PROCEDURE Show SQL_STORED_PROCEDURE
⇒ Ending Stored Procedures Properly in SQL Server
⇐ "DROP PROCEDURE" - Dropping an Existing Procedure in SQL Server
2017-01-05, 3251🔥, 0💬
Popular Posts:
How To Update Multiple Rows with One UPDATE Statement in SQL Server? If the WHERE clause in an UPDAT...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...
How to download and install Microsoft .NET Framework Version 2.0 in SQL Server? .NET Framework Versi...
How To Start Instance with a Minimal Initialization Parameter File in Oracle? The sample initializat...