-- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE PROCEDURE dbo.GetEmployeeDetails -- Add the parameters for the stored procedure here @EmployeeID INT = 0, @Department NVARCHAR(50) = NULL AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT * FROM Employees WHERE (EmployeeID = @EmployeeID OR @EmployeeID = 0) AND (Department = @Department OR @Department IS NULL); END GO Use code with caution. Copied to clipboard How to use this file:
To create a stored procedure in SQL, you typically use a .sql file, though you can save the code in a .txt file for documentation or manual execution. Download CREATE PROCEDURE txt
: Keep it as a .txt file for sharing or change the extension to .sql to run it directly in tools like SQL Server Management Studio (SSMS) or MySQL Workbench. : Keep it as a