Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Crud Operations In SQL Using Storedprocedure

In this article i explain you how to write crud operations in sql using stored procedure we have an senario
to write all operations write in single stored procedure
Example:-
Step1:- Create Table
Create Table Employee
(
Id                  int primary key identity,
Name            varchar(50),
Designation    varchar(50),
Gender         varchar(50),
Salary           int
)
Step2:-Insert some data into table
Insert Into Employee values('Vasu','Developer','Male',25000)
Insert Into Employee values('kiran','Developer','Male',30000)
Insert Into Employee values('madhu','Tester','Female',40000)
Insert Into Employee values('manasa','Tester','Female',50000)

How To Resolve SQL Connection In SQL Server

In this article i explain you how to resolve sql connection when we connecting to sql server
Below is the screen

Step1:- Go to SQL Configuration Manager
Select SQL SERVER(MSSQLEXPRESS) right click on that then see if it stop click start

Stil if in case it is not work

HOW TO GET TABLES LIST IN SQL SERVER DATABASE

In this articel i explain you how to get list of tables in sql server database
Below is the query
Gets list of tables 
SELECT*FROM SYSOBJECTS WHERE xtype='U'
     (OR)
SELECT *FROM sys.tables
Gets list of tables and views
SELECT *FROM INFORMATION_SCHEMA.TABLES
Gets list of stored procedure
SELECT*FROM SYSOBJECTS WHERE xtype='P'
Gets list of views
SELECT*FROM SYSOBJECTS WHERE xtype='V'
To get the list different objects types(xtype) from database
SELECT DISTINCT xtype FROM SYSOBJECTS

What is the difference between inline table valued and multi statement valued functions in SQL

In this article i explain you how to declare inline table valued functions and multi-statement valued functions in sql
 In line table valued functions :-
Create Function fnILTVF_GetEmployees()
Returns Table
as
Return (Select Id, Name, Cast(DateOfBirth as Date) as DOB
        From tblEmployees)
Multi-statement Table Valued function :-
Create Function fnMSTVF_GetEmployees()
Returns @Table Table (Id int, Name nvarchar(20), DOB Date)

Transactions in SQL Server

What is a Transaction?

A transaction is a group of commands that change the data stored in a database. A transaction, is treated as a single unit. A transaction ensures that, either all of the commands succeed, or none of them. If one of the commands in the transaction fails, all of the commands fail, and any data that was modified in the database is rolled back. In this way, transactions maintain the integrity of data in a database.

OPTIONAL PARAMETERS IN SQL USING STORED STORED PROCEDURE

In this article i am going to tell you how to create stored procedure with optional parameters

STEP 1: - CREATER TABLE

CREATE TABLE tblEmployees
(
Id  int primary key identity,
EmpName   varchar(50),
Gender    varchar(50),
Salary    int
)

HOW TO CREATE STORED PROCEDURE IN SQL SERVER

STEP 1:-  CREATE TABLE

CREATE TABLE tblEmployees
(
Id  int primary key,
EmpName   varchar(50),
Gender    varchar(50),
Salary    int
)

HOW TO CREATE TABLE IN SQL SERVER

STEP 1:- CREATE TABLE

CREATE TABLE tblEmployees
(
Id  int primary key,
EmpName   varchar(50),
Gender    varchar(50),
Salary    int
)