SQL SERVER Intro


Introduction

Microsoft SQL SERVER Certification

LINKS

In the absense of material provided here is a list of links to SQL topics:

Transact-SQL

  • Data definition language statements
  • data control language statements
  • Data manipulation language statements

Define the database object

Comments


SELECT * FROM table -- this is a comment

Attach a Database

To import a *.mdf file:

  1. right-click the Databases icon and select Attach...
  2. Click Add... to add a database to the list
  3. Click OK to import the databases

Create a .txt SQL script

Open notepad and type:


USE demo
SELECT * FROM category

Save it as cat.txt

Grab the name of the server by right-clicking the server, selecting properties and copying it

Mine is: ICTVM-AHBC4DH7R/SAIT

Open up the command prompt (cmd.exe) then type:


osql -S ICTVM-AHBC4DH7R/SAIT -i c:\__SQL\cat.txt -E

...to run the command as a script

Commands

There are many keywords in SQL:

  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data in a database
  • INSERT INTO - inserts new data into a database
  • CREATE DATABASE - creates a new database
  • ALTER DATABASE - modifies a database
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index