How to Write Basic SQL Statements in SQL Server
How to Write Basic SQL Statements in SQL Server
If you work with databases frequently, you might have to occasionally write basic SQL queries to retrieve and manipulate the data you need. The best way to write SQL commands is in SQL Server Management Studio. Luckily, it's pretty easy, even if you're a beginner to writing SQL. We'll show you some basic commands, like the SELECT statement, INSERT statement, and more!



1) SELECT - This command is used to retrieve information from a table
2) INSERT - This command is used to add information to a table

3) UPDATE - This command is used to modify information to a table

4) DELETE - This command is used to remove information from a table
Steps

Click on Start --> All Programs --> Microsoft SQL Server (2005/2008) --> SQL Server Management Studio

Next Login with your credentials to the Server

Now right click on the Northwind Database and choose New Query

In the new Query Window, enter the following command for SELECT

This is the syntax for SELECT - SELECT * FROM Employees

This is the syntax for INSERT - INSERT INTO Employees VALUES('col1', 'col2') - Replace col1 and col2 with actual Values as shown below INSERT INTO Employees values('Anil','[email protected]') This inserts a single row into the table.In the even you wish to enter multiple rows at one go, you see the following command INSERT INTO Employees values('Anna','[email protected]'), INSERT INTO Employees values('Krystel','[email protected]'), INSERT INTO Employees values('Lines','[email protected]'). The key difference here is that every value is appended by a comma

What's your reaction?

Comments

https://wapozavr.com/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!