Showing posts with label sql server 2008. Show all posts
Showing posts with label sql server 2008. Show all posts

Friday, 17 October 2014

Part 2 Creating and Drop a Database

In  part 1 What is SQL Server we understand the concept SQL Server 2008 and How to connect to SQL server. In this Session we understand how to create or delete the database. There are two ways to do almost everything in SQL Server 2008

  • Graphically with SSMS
  • With Query
First we talk How to create or delete Graphically

open your SSMS go to object Explore Right click on database folder and select New Database.


Part 2 Creating and Drop a Database

After that a New Database dialog box appear

Set the Database Name <DB Name> what ever you want My is Sample 1 and click OK

Expand Database folder and new database is created name Sample 1.
If database is not shown for some reason just Right click  Database folder and refresh .

Now we create a database using Query

Create Database <DB_Name>

When we create a database behind the scenes two files are created
to get to the file Right click the database and click properties

Properties Window opens. select file Go to the path

Copy that path and past to run window.. to open run click window button + R.
There are 2 files .mdf and log.ldf

these two file are associated  with a database we created.
.mdf is actual database file (Master Database File)
.log.ldf is Transaction log file (its a recovery file)

Now we discuss how to rename the DB graphically
just Right Click the DB and click rename

there are two ways to write a query for rename DB

Alter Database <Original name> Modify Name = <New Name>
OR
By system store procedure. store procedure are covered later session For now understand they are only a group of commands.
and there are 2 types of store procedure user define store procedure and system store procedure as name suggest user store procedure are created by user and system store procedure are provided by

Execute sp_renameDB'OldName','NewName'

Now we discuss how to delete DB
Grapically
Right Click DB and click Delete

By Query

drop database <DB Name>

Thursday, 16 October 2014

Part 1 What is SQL Server


Sql server and database are two different things.

Sql server management studio is a client tool which is use to do operations on database  with commands terms as queries. SSMS is not a database.

 all table, views, triggers are created by SSMS and stored on one database.

SSMS give us flexibility of multi-user operate single database environment.

 

Connecting to Sql server 2008

Start -> All Programs -> Microsoft SQL Server 2008 -> SQL Server Management Studio

a connecting window shows up


first you  see  server type. There are different server type shown in dropdown list. select Database Engine, we'll talk other types later
server name 

If you have the multiple user environment shown in figure 1 above set the server name as your pc name or your pc IP address. 
In my case I can select my local pc name as (local) or . or IP

Authentication 
there are two type of authorizations Windows authentication and Sql Server  authentication 
these type are depends on How you install sql server. If you install mix mode both type are shown, if you sql server only Sql Server  authentication 

If you select Sql Server  authentication you need to give username and password where as if you select Windows authentication Windows authentication there is no need of giving username and password and click connect 

the instance of sql server is created and connect 


after connecting  this screen is shown. To write a query click New Query button a query editing window generated. In next session we write query and create user define database.