Select Statement in mssql:
Syntax : Select * from [tablename]
Ex : Select * from Employee
Select Statement by ID in mssql:
Syntax : Select * from [tablename] where Id=[value]
Ex : Select * from Employee where ID= 100
Select Statement by using like operator in mssql:
Ex : Select * from Employee where Name like 'E%' --Name starts with 'E'
Select * from Employee where Name like '%E'
--Name Ends with 'E'
Select * from Employee where Name like '%E%' --Name Contains 'E' letter
Delete Statement in mssql:
Syntax : Delete from [tablename]
Ex : Delete from Employee
Delete Statement by ID in mssql:
Syntax : Delete from [tablename] where Id=[value]
Ex : Delete from Employee where ID= 100
Insert Statement in mssql:
Syntax : Insert Into [tablename] (column1,column2,column3,.......) values (Values1,Values2,Values3,.......)
Ex : Insert Into Employee (Name,UName,Password,Mobile No,E-mail) values ('Name1','Name1','psd','23424333','abc@xyz.com')
Update Statement in mssql:
Syntax : Update [tablename] Set column1=Values1,column2=Values2,column3=Values3,.......
Where ColumnN=ValueN
Ex : Update Employee Set Name='Name2',UName='Name_test',Password='pwd',Mobile No='234242323' ,E-mail='def@xyz.com'
Select Distinct Statement in mssql:
Syntax : Select Distinct ColumnName from [tablename]
Ex : Select Distinct Name from Employee ---It can get the data unique entries only (no duplicates)
Select Statement with 'And' Operator in mssql:
Syntax : Select * from [tablename] where Column1=value1 and column2='Value2'
Ex : Select * from Employee where Id=100 and Name='Name1'
Select Statement with 'OR' Operator in mssql:
Syntax : Select * from [tablename] where Column1=value1 or column2='Value2'
Ex : Select * from Employee where Id=100 or Name='Name1'
Select Statement with order by in mssql:
Syntax : Select * from [tablename] order by column2
Ex : Select * from Employee order by Name --- getting data by default in ascending order
Ex : Select * from Employee order by Name Desc --- getting data in descending order
Aliases in mssql:
Syntax : Select * from [tablename] as TN
Ex : Select * from Employee as Emp ----Here as is the alias 'Emp' is the Alias name of the Employee
Count in mssql:
Syntax : Select Count(column1) from [tablename]
Ex : Select Count(Name) from Employee --- Then we get the Number of Names(rows) in the table
Joins in the mssql:
Syntax : Select * from [tablename] as tn1 Join Table2 as t2 ON t1.Id=t2.tnId
Ex : Select * from Employee as emp Join Department as dept ON emp.Id=dept.EmpId
Sum Operator in the mssql:
Syntax : Select SUM(Column1) from [tablename]
Ex : Select SUM(Amount) from Sales ---- In this statement we will get the sum of the sales amount with in the table
Average Operator in the mssql:
Syntax : Select AVG(Column1) from [tablename]
Ex : Select AVG(Amount) from Sales ---- In this statement we will get the Average of the sales amount with in the table
Min Operator in the mssql:
Syntax : Select MIN(Column1) from [tablename]
Ex : Select MIN(Amount) from Sales ---- In this statement we will get the Minimum sales amount with in the table
Max Operator in the mssql:
Syntax : Select MAX(Column1) from [tablename]
Ex : Select MAX(Amount) from Sales ---- In this statement we will get the Maximum sales amount with in the table
Not In Operator in the mssql:
SELECT * from UserDetails where
UID not in (10,11,12,13,29)
--here we get the data of which not have the ids of 10,11,12,13,29
UID not in (10,11,12,13,29)
--here we get the data of which not have the ids of 10,11,12,13,29
In Operator in the mssql:
SELECT * from UserDetails where
UID in (10,11,12,13,29) --here we get the data of which have the ids of 10,11,12,13,29
UID in (10,11,12,13,29) --here we get the data of which have the ids of 10,11,12,13,29
Get the Procedure in the mssql:
Syntax : sp_helptext "StoredProcedureName"
sp_helptext USP_IC_IsolationEquipment_ GetEquipments
Execute the Procedure in the mssql:
Syntax : Exec StoredProcedureName Parameter1,Parameter2,Parameter3,....
Ex : exec USP_Equipment_ GetEquipments 4,3
Ex : exec USP_Equipment_