Sql Select Query
SQL Select all data from Table as you can see in my previous Articlehttp://learningmvctutorial.blogspot.in/2017/03/sql-select.html
Insert Query
In SQL Server you can use Insert data in table help of Insert QuerySyntax
INSERT INTO TableName(ColumnName1,ColumnName2,ColumnName3) VALUES(@value1,@value2,@value3)
Note- In this Insert Query those Column you want to insert in table then define column name and give there values according field data type.
This is Syntax and you can see example so more clear about this query
Example
INSERT INTO Tbl_Employee(Name, Salary,City) VALUES ('Radhe',40000,'Jaipur')
Note -You can write this query and Run f5 then Show message "(1 row(s) affected)" Result - You can run select query and see output record.
Update Query
In SQL Server you can use update record in table help of Update QuerySyntax
UPDATE TableName SET ColumnName1=@value1,ColumnName2=@value2 WHERE ColumnName Condition OPERATORE
Note- In this Update Query those existing Column you want to update in the table then define column name and set values according field data type if you want to give where condition then give if you not give where condition then reflect all this full of table.
This is Syntax and you can see example so more clear about this query
Example
UPDATE Tbl_Employee SET Name = 'Sita', Salary=12000 WHERE Id=4
Note -You can write this query and Run f5 then Show message "(1 row(s) affected)" Result - You can run select query and see output record.
Delete Query
In SQL Server Delete query is used to delete record in SQL server.You can see exampleSyntax
DELETE FROM TableName WHERE ColumnName Condition operator
Note- In this Delete Query those record you want to delete from table then use this delete query if you want to delete record according condition then use 'where Clause' and use which record you want to delete use this condition , if you not give where condition then reflect all this full of table.
This is Syntax and you can see example so more clear about this query
Example
DELETE FROM Tbl_Employee SET Name = 'Sita', Salary=12000 WHERE Id=4
Note -You can write this query and Run f5 then Show message "(1 row(s) affected)" Result - You can run select query and see output record.
SQL In Operator
In SQL Server In Operator use to multiple value use in where clause.You can use In operator and apply more than 1 values in where clause and get result according match values you can see In operator exampleSyntax
SELECT ColumnName
FROM TableName
WHERE ColumnName IN (value1,value2,...)
Note- Use this syntax find easily match record using In operator, Basically use In Sytax and give vales in where clause whatever you want to match.
This is Syntax and you can see example so more clear about this query
Example
SELECT Name
FROM Tbl_Employee
WHERE City IN ('Chittorgarh','Jaipur')
Note - You can write this query and Run f5 then You find result employee name those belongs city is Chittorgarh and Jaipur" Result - You can run select query and see output record.
SQL Between Operator
In SQL Server Between Operator is used to select values within a range Commonly use for rang. You can see exampleSyntax
SELECT ColumnName
FROM TableName
WHERE ColumnName Between value1 and value2
Note- Use this Syntax find record within range using Between operator, Basically use In syntax and give vales in where clause whatever you want to define rang.
This is Syntax and you can see example so more clear about this query
Example
SELECT Name
FROM Tbl_Employee
WHERE Salary Between 1000 and 30000
Note -You can write this query and Run f5 then You find result employee name those Salary between 1000 to 30000" Result - You can run select query and see output record.
ALTER Commands
The SQL ALTER TABLE command is used to add, delete or modify columns in an existing table.
You would also use ALTER TABLE command to add and drop various constraints on a an existing table.
Add new column in existing table through Alter Command
Add new column in existing table through Alter Command
ALTER TABLE table_name ADD column_name datatype;Drop column in existing table through Alter Command
ALTER TABLE table_name DROP COLUMN column_name;Change The Data Type of column in existing table
ALTER TABLE table_name MODIFY COLUMN column_name datatype;Add NOT NULL constraint to a column
ALTER TABLE table_name MODIFY column_name datatype NOT NULL;
0 comments :
Post a Comment