
Search In
In this article we will learn how to check if a stored procedure exists before creating it. We can use the below script which will drop the proc if it exists and then recreate it.
IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'sp
For doing that we need to create procedure first and also define the repeating interval to call it again
We will create procedure named getnotification from the particular database that gets fired after 3:30 hours on a daily basis.
When we gets
ALIAS Keyword:
It is used to give temporary names to table and columns. It is very useful for situations where column or table names are too long.
Synatx:
SELECT columnname AS alias_name FROM tablename;
This syntax is used for giving te
To provide searching optimization we need to create indexes in the table. By default primary key is already indexed
For searching by other columns apart from primary key we will create index into them for faster searching.
Ex: CREATE INDEX na
In SQL we can create the primary key
Ex: create table student
(
stid int primary key identity(1,1),
stname varchar(50)
)
In SQL we can also create the foreign key using SQL query
Ex: create table account
(
staccid int primary ke
Triggers in SQL of a table can be find by writing a SQL query and passing table name as its parameter for the query
We will just pass the table name for that and it will provide all the triggers made for that table.
Ex: select so.name, text
fro
Identity field is usually used as a primary key. When you insert a new record into your table, this field automatically assign an incremented value from the previous entry.
Ex:
CREATE TABLE Customer
(
ID int IDENTITY,
SQL Server has an exception model to handle exceptions and errors that occurs in SQL statements. To handle exception in Sql Server we have TRY..CATCH blocks. In Sql Server, against a Try block we can have only one CATCH block.
Ex;
BEGIN TR
Sometimes we required to remove duplicate records from a table although table has a UniqueID Column with identity.
Ex: CREATE TABLE dbo.Employee
(
EmpID int IDENTITY(1,1) NOT NULL,
Name varchar(55) NULL,
Salary decimal(10, 2
In SQL we have situations, where we want to manipulate our data based on conditions .
For doing that one approach we need is to store that data into temp table then manipulate it.
For doing this we copy the entire structure of the main table in
