PDF download Download Article PDF download Download Article

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

  1. Advertisement
  2. 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','anil@company.com')
    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','anna@company.com'), INSERT INTO Employees values('Krystel','krystel@company.com'), INSERT INTO Employees values('Lines','lines@company.com'). The key difference here is that every value is appended by a comma
  3. Advertisement
    7
  4. This is the syntax for UPDATE - UPDATE Employees SET col1 = 'new value' WHERE col1 = 'old value' - Replace col1 with actual Values as shown below
  5. UPDATE Employees SET Name = 'Anil Mahadev' WHERE Name = 'Anil'
  6. This is the syntax for DELETE - DELETE FROM Employees WHERE col1 = 'value' WHERE value = 'actual data row' - Replace actual data row with actual Values as shown below
  7. DELETE FROM Employees WHERE Name = 'Anil Mahadev'
  8. This completes this short How-To, I hope this has been beneficial to you and like to Thank You for viewing it.
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
  • Use the SQL Server Management Studio Code Snippets as hints to better your SQL Writing Skills
  • As you become more comfortable writing Queries, Use the SQL Query Designer to build sophisticated queries
  • Never use DELETE without a WHERE Clause in your Statements to prevent accidental deletion of rows
  • Same rule applies to UPDATE and INSERT as well
  • Always use Caution when working with the DELETE command.

Community Q&A

Search
Add New Question
  • Question
    Can you explain the steps from creation of a database to the retrieval of data from it?
    Community Answer
    Community Answer
    Database management is more complex than a single question and answer can explain. There are many free tutorials online. Start by googling "SQL tutorial" and see what you find.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement

You Might Also Like

Create a SQL Server DatabaseCreating a Database With SQL Server Management Studio
Use Microsoft AccessThe Ultimate Guide to Using Microsoft Access
Delete Duplicate Records in OracleEverything You Need to Know About Removing Duplicate Records in Oracle
Create a Database in MySQLCreate a Database in MySQL
Edit Data in Microsoft Excel3 Simple Ways to Edit Data in MS Excel
Order Alphabetically in SQL Order Alphabetically in SQL
Reset SA Password in SQL ServerReset SA Password in SQL Server
Send SQL Queries to MySQL from the Command LineSend SQL Queries to MySQL from the Command Line
Open an SQL FileView and Edit SQL Files: MySQL Workbench, Excel, & More
Make a Database Using MS AccessMake a Database Using MS Access
Program with VBScriptProgram with VBScript
Insert Rows in Excel Add or Delete Rows in Microsoft Excel: 4 Simple Ways
Check the Query Performance in an SQL Server Check SQL Server Query Performance: Step-by-Step Guide
Make a Spreadsheet in ExcelMake a Spreadsheet in Excel
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 13 people, some anonymous, worked to edit and improve it over time. This article has been viewed 121,000 times.
How helpful is this?
Co-authors: 13
Updated: November 23, 2021
Views: 121,000
Categories: Databases
Thanks to all authors for creating a page that has been read 121,000 times.

Is this article up to date?

Advertisement