Posts

STORE PROCEDURE ADVANCE CONCEPT - PART 2

  List All Stored Procedures SELECT name FROM sys.procedures; ================================================================================ Stored Procedure Calling Another Stored Procedure with Parameters in SQL Server You cannot create a stored procedure inside another stored procedure, but you can call one stored procedure from another and pass parameters . Step 1: Create Table CREATE TABLE Employee ( EmpID INT IDENTITY ( 1 , 1 ) PRIMARY KEY , EmpName VARCHAR ( 100 ), Salary DECIMAL ( 10 , 2 ) ); Step 2: Insert Sample Data INSERT INTO Employee(EmpName, Salary) VALUES ( 'Nilesh Gupta' , 50000 ), ( 'Rahul Sharma' , 45000 ), ( 'Priya Patel' , 55000 ); ====================================================================================== Procedure 1: Get Employee by ID CREATE PROCEDURE sp_GetEmployeeByID ( @EmpID INT ) AS BEGIN SELECT * FROM Employee WHERE EmpID = @EmpID; END ; GO Execute EXEC sp_GetEmployeeByI...

STORE PROCEDURE BASIC PROGRAMMING - PART 1

  1. Create a Stored Procedure CREATE PROCEDURE sp_GreetUser AS BEGIN PRINT 'Welcome to SQL Server Stored Procedure Programming' ; END ; ================================================================================ Stored Procedure with Parameters Create Procedure CREATE PROCEDURE sp_AddNumbers @Num1 INT , @Num2 INT AS BEGIN DECLARE @ Result INT ; SET @ Result = @Num1 + @Num2; PRINT 'Addition Result = ' + CAST (@ Result AS VARCHAR ( 10 )); END ; Execute Procedure EXEC sp_AddNumbers 10 , 20 ; ========================================================================== Stored Procedure with Parameters Create Procedure CREATE PROCEDURE sp_AddNumbers @Num1 INT , @Num2 INT AS BEGIN DECLARE @ Result INT ; SET @ Result = @Num1 + @Num2; PRINT 'Addition Result = ' + CAST (@ Result AS VARCHAR ( 10 )); END ; Execute Procedure EXEC sp_AddNumbers 10 , 20 ; ======================...

Constraints

 constraint with example in sql server In Microsoft SQL Server , Constraints are rules applied on table columns to maintain data accuracy and integrity. Types of Constraints in SQL Server PRIMARY KEY FOREIGN KEY UNIQUE NOT NULL CHECK DEFAULT 1. PRIMARY KEY Constraint Uniquely identifies each record. Does not allow NULL . Example CREATE TABLE Students ( StudentID INT PRIMARY KEY , StudentName VARCHAR ( 100 ) ); 2. FOREIGN KEY Constraint Creates relationship between two tables. Example CREATE TABLE Department ( DeptID INT PRIMARY KEY , DeptName VARCHAR ( 50 ) ); CREATE TABLE Employee ( EmpID INT PRIMARY KEY , EmpName VARCHAR ( 100 ), DeptID INT , CONSTRAINT FK_Employee_Department FOREIGN KEY (DeptID) REFERENCES Department(DeptID) ); 3. UNIQUE Constraint Prevents duplicate values. Allows one NULL value. Example CREATE TABLE Users ( UserID INT PRIMARY KEY , Email VARCHAR ( 100 ) UNIQUE ); 4. NOT NULL Constraint Do...

Python Introduction

PYTHON PROGRAMING https://thonny.org/ Python supports multiple programming paradigms, including object-oriented, procedural, and functional programming . It provides a rich standard library and a large ecosystem of third-party packages, which helps developers to build applications faster and more efficiently. Python is platform-independent, meaning Python programs can run on Windows, Linux, and macOS without modification. Due to its flexibility and powerful features, Python is widely used in fields such as: ·          Web Development ·          Data Science & Data Analytics ·          Artificial Intelligence & Machine Learning ·          Automation & Scripting ·          Desktop Application Development · ...