SQL Basics

We know that SharePoint content are stored in SQL Server. So, I thought it would be nice to know about SQL Server.

What is SQL?

SQL stands for structured Query Language. It is used for accessing and manipulating database where Database is a collection of data and Data are Raw facts.

CREATING DATABASE:

  • Open SQL Server Management Studio and connect it using necessary authentication
  • We can see Databases in Object Explorer as shown below
  • Right click on Database and select New Database

 

new database

  •  Provide a name for the database(say, Sathiya) and click OK

database

  •  Once database is created, we can see our databases in object explorer
  • Expand Databases to find our database Sathiya
  • Expand the Database, Sathiya to find Tables
  • Right click on the Table -> New Table to create a table

Table

  • Enter the columns to be created in the table with corresponding data type
  • Check “Allow Nulls” to make it “Mandatory”

empDetails

  • Click on Save icon or File->Save
  • Enter the name for the table in “Choose Name” dialog box(say, EmpDetails) and click OK button

Emp

  • Now, we have to enter the data in the table
  • To do so, expand Tables under our database, Sathiya in Object Explorer
  • We can find our table as “dbo.EmpDetails”
  • Right click on it and select “Edit Top 200 rows”

Edit rows

  • Provide the data in the table and save it as shown below

save

CREATING DATABASE USING T-SQL(Transact SQL):

  •  To create database using T-SQL, click on New Query located below File menu

newquery

  • We will see list of databases located before “Execute” button
  • Select “Master” database and type the create statement in “Query Editor Window”
  • SYNTAX: create database databasename;
  • Execute the command

creaate

  • To create a table with necessary columns in Akash Database use the below T-SQL and press F5
  • SYNTAX: create table tablename     { column1 datatype, column2 datatype}

empname

  • Insert data into above created table using insert statement
  • SYNTAX: insert into tablename (column1,column2) values (a,b);

insert

  • Finally, view the table using select statement

limit

 

 

Advertisements

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s