Create a database and exploring stored procedures in sql

Assignment Help Database Management System
Reference no: EM131184769

Creating a Database and Exploring Stored Procedures in SQL Server 2008 Tutorial

Lab Objective

This lab will allow you to create a new database, insert a table into the database, and use SQL Server Management Studio to create a stored procedure in that database. This feature allows a Database Administrator to manage and maintain the database.

Required Materials

- SQL Server 2008 (Express or Full Version)
- Creating a Database and Exploring Stored Procedures in SQL Server 2008 Tutorial (this document)

Procedures

Create a new sample database called MyDB
Open SQL Server Management Studio
In the Object Explorer Window, right click on Databases
Select New Database

NOTE: At four places in this lab, you will be asked to capture your screen and paste the image into a Word file, which you will submit in the dropbox for Module 7.

In the Database Name box, type MyDB
Click OK

Add a table to the database
Click the + Sign next to the MyDB file to expand the database
Right Click on Tables
Choose New Table
Create columns for ID, LastName, FirstName as shown below:

Now set the ID field as the primary key.
Click on the ID row, then the Table Designer menu, then Set Primary Key

NOTE: If you were creating multiple related tables (such as in your project), you would also need to define relationships-but today we'll concentrate on stored procedures).

Click FILE, SaveTable1, enter the name as Employees, then OK

At this point, capture your screen and paste into the Word file you will submit (First screen shot)

Now create a stored procedure to add a row of data into your table.
Enter a new query:
Create procedure Add_Employee
@ID int,
@FirstName nvarchar(10),
@LastName nvarchar(10)
as
Insert into dbo.Employees(ID,FirstName,LastName)
Values(@ID,@FirstName,@LastName)

Click the execute button. If you get errors, fix and re-execute. If there are no errors, continue.

Right click the Programmability folder and select Refresh. You should see the Add_Employee procedure. Expand the Parameters to see @ID, @FirstName,@LastName as shown in the next diagram.

At this point, capture your screen and paste into the Word file you will submit (Second screen shot)

Rightclick Add_Employee and select Execute Stored Procedure. When the window appears asking for data, enter an ID number, and your first and last name.

Click OK. "Query executed successfully should appear at the bottom of the page.

NOTE: If you try to execute the query more than one time with exactly the same data, you will get an error. You can duplicate the names, but since the ID is the primary key, each record must have a unique value for this field.

Verify that the new Employee was added by running a Select query on the Employees table.
Select * from dbo.Employees

At this point, capture your screen and paste into the Word file you will submit (Third screen shot-make sure YOUR name shows up in the query results!!)

Now try an alternate method of executing the procedure: In the New Query window, enter the following and press Execute to run:

Execute Add_Employee'46','Larry','Smith'

Now, rerun your query to verify that the additional row was added.

At this point, capture your screen and paste into the Word file you will submit (Fourth screen shot)

Save the Word file and submit in dropbox for this week.

If you have problems, please send screen shots of your errors when you contact instructor.

Attachment:- Create_Database.pdf

Reference no: EM131184769

Questions Cloud

What is the nature of the world around us : Write an 800-1,000-word essay on your personal worldview. Briefly discuss the various possible meanings of the term "spirituality," and your understanding of the concepts of pluralism, scientism, and postmodernism. What is the nature of the world ..
What is the differential-mode input impedance : For the differential amplifier shown in Fig. 4-8, R1 and R2 are 1% resistors with values of 4.7 k Ω and 270 k Ω, respectively.
Apply strategies for helping people cope with change : By the end of this week, you should be able to: Explain the role of leadership in fostering and supporting change and Apply strategies for helping people cope with change
Evaluate current network solutions : Complete an 8- to 10-slide Power Point presentation that represents a comprehensive network design.The presentation should represent an organization's network, including WAN, LAN, and Home User designs.
Create a database and exploring stored procedures in sql : Creating a Database and Exploring Stored Procedures in SQL Server 2008 Tutorial. Create a new sample database called MyDB. Create columns for ID, LastName, FirstName.
Which case would have most weight if you lived in ontario : State briefly, giving reasons, which case would have the most weight if you lived in Ontario. If you lived in BC, how would you distinguish the Roy case if you were acting for a hockey player who had been injured by a deliberate act by a player on ..
What is the characteristic impedance of the line : What will be the phase shift of a 10-MHz sine wave after it travels a distance of ten feet on the line?
Development of the clients database system : You are required to present an overview of the fact-finding techniques that your company intends to use to support the development of the client's database system.
Why is this philosophical system a good approach to living : Then, discuss one in particular that appeals to you and explain why. Specifically, why is this philosophical system a good approach to living a good life

Reviews

Write a Review

Database Management System Questions & Answers

  Write the application for university admissions office

Write the application for university admissions office. Prompt user for a student's High School Grade Point and an admission test score.

  Create the roles, and grant the appropriate privileges to it

Look at attach Figure. Your job is to write the code that implements the matrix using three roles: CHIEF_EDITOR, WRITERS, and EDITORS

  Display last name customer associated with order id

You have to write a query to display last name customer associated with order id in given database.

  Write a select statement that returns an xml document

Write a SELECT statement that returns an XML document that contains all of the invoices in the Invoices table that have more than one line item.

  Aspects of tablespace management

Respond to the following in 100 words or less.  Work must be cited.

  Examine use of database applications in organization

Prepare a memorandum examining use of databases in organization. Write database applications are used: Microsoft Access, DB2, Oracle, etc.

  Create a database and modify your script

Create a Database and modify your script to reference your Database and Running script file in MySQL, create SQL SELECT Queries

  Draw relationship diagram for arrays

Information Gathering Component is very important to a shopping cart system. You really want to develop a good algorithm for it. As a professional practice, you decided to first make a working plan in pseudocode before putting hands.

  Display the last name and phone number of all dog owners

Display the last name and phone number of all dog owners. Use a subquery to do this. Display the first and last name of owners and the type of animal of all unknown breeds. Display the pet name and owner last name of all dogs.

  Return a result table sorted by patient name

Return a result table that could be used to produce a report, sorted by patient name or date, for a particular week or after a particular date, or a listing of patient visits for patients assigned to a specific social worker

  Schema design part i the following describes what is

schema design part i the following describes what is expected in the design part of the assignment.1 dfd and er diagram

  Database application improvements question

Submit an Executive Memo addressed to the CIO and the board of directors. Last week, the CIO reviewed your presentation and has decided to move forward with your recommendations for improvements.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd