Portfolio

Wednesday, September 16, 2015

SQL Server Queries- Introduction to Writing Basic Queries

Here is a simple example of how to write basic queries in SQL.

Before you get started you need to install Microsoft SQL Server Management Studio.  I'm using Microsoft SQL Server 2014 and you can purchase that on Amazon for a reasonable price.  I bought it on Amazon for around $36.00.  But you need to get a SQL Server editor to write basic queries to get a feel for doing the exercises on your own.



--How to Create Database—
Create Database tblPerson



--How to create table in SQL Server--

Create Table tblPerson
(
ID int NOT NULL,
Name nvarchar (50),
Email nvarchar (50),
GenderID int,
)
--How to insert values into columns--
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Mary Jones', 'maryjones@gmail.com', 1);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Bobby Womack', 'bobbywomack@gmail.com', 2);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Bart Simpson', 'bartsimpson@gmail.com', 3);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Marge Simpson', 'margesimpson@gmail.com', 4);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Lisa Simpson', 'lisasimpson@gmail.com', 5);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Judy Shieildlin', 'judyshieldlin@gmail.com', 6);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Julian Mariani', 'juilianmariani@gmail.com', 7);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Donald Duck', 'donaldduck@gmail.com', 8);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Mary Jones', 'maryjones@gmail.com', 9);
Insert into tblPerson (ID, Name, Email, GenderID) Values (1, 'Mary Jones', 'maryjones@gmail.com', 10);

Select * from tblPerson;

This is a basic way to create a database and table in SQL Server. 



 














No comments:

Post a Comment