How to Write Basic Sql Statements in Sql Server

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...

15 Steps 1 min read Advanced

Step-by-Step Guide

  1. Step 1: Click on Start --> All Programs --> Microsoft SQL Server (2005/2008) --> SQL Server Management Studio;

    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 ,,,,,
  2. Step 2: Next Login with your credentials to the Server

  3. Step 3: Now right click on the Northwind Database and choose New Query

  4. Step 4: In the new Query Window

  5. Step 5: enter the following command for SELECT

  6. Step 6: This is the syntax for SELECT - SELECT * FROM Employees

  7. Step 7: This is the syntax for INSERT - INSERT INTO Employees VALUES('col1'

  8. Step 8: 'col2') - Replace col1 and col2 with actual Values as shown below INSERT INTO Employees values('Anil'

  9. Step 9: '[email protected]') This inserts a single row into the table.

  10. Step 10: This is the syntax for UPDATE - UPDATE Employees SET col1 = 'new value' WHERE col1 = 'old value' - Replace col1 with actual Values as shown below

  11. Step 11: UPDATE Employees SET Name = 'Anil Mahadev' WHERE Name = 'Anil'

  12. Step 12: 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

  13. Step 13: DELETE FROM Employees WHERE Name = 'Anil Mahadev'

  14. Step 14: This completes this short How-To

  15. Step 15: I hope this has been beneficial to you and like to Thank You for viewing it.

Detailed Guide

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 ,,,,,

About the Author

N

Nancy Gomez

Enthusiastic about teaching hobbies techniques through clear, step-by-step guides.

108 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: