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

  Protecting data warehouses and employee privacy

What should a company consider installing on the network perimeter to prevent direct connections between the internal network and the Internet to help protect its data warehouses and employee privacy?

  How replication works with distributed database

Provide an example of what kind of application would be able to take advantage of a distributed environment. Support your suggestion.

  Relational database concepts and applications

Relational Database Concepts and Applications

  Imagine that you work for a consulting firm that offers

imagine that you work for a consulting firm that offers information technology and database services. part of its core

  Write a select statement that answers this problem

Write a SELECT statement that answers this problem - Which products have a list price that's greater than the average list price for all products?

  Co-related sub-query to return one row per customer

Use a co-related sub-query to return one row per customer, representing the customer's oldest order (the one with the earliest date).

  Alexander, the great: strength, weakness and contributions

There were immense qualities for Alexander, the great as a leader. One of the greatest qualities a leader should have is ambition.

  Integrate different technologies from different partners

The IT role for this project is to integrate different technologies from different partners and incorporate industry best practices and cost-effective solutions in connection with the development of technological systems and to implement proper se..

  Gap is developing its database using object-oriented methods

Assume that GAP is developing its database using object-oriented methods. Assume further that the database designers want to make some changes to the class diagram on next page. Specifically, they want to make ProductItem an abstract parent clas..

  How are the two computer styles different

How did the management of data shift from a mainframe system to a PC-based computing system?

  Techniques to store and retrieve data using an sql database

Develop an understanding of strengths and limitations of various data storage, retrieval methods and models. The assessment requires students to conduct a survey and report on data storage and retrieval techniques and data models.

  Creating erd containing order and customer entity

Create ERD containing Order and Customer entity types connected by 1-M relationship from Customer to Order. Select suiatble relationship name using your common knowledge of intersection.

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