How to write a procedure?

Write a script to create a stored procedure in T-SQL.?

  • Write a script to create a stored procedure in T-SQL. The stored procedure should update a row in the Employee table provided below. It should accept an Employee's Name and EmailAddress and PositionID. Using the Name and EmailAddress, the stored procedure should update that employee's position. Employee Name varchar(50) EmailAddress varchar(250) Birthdate datetime Startdate datetime Enddate datetime PositionID int DepartmentID int Department DepartmentID int Name varchar(50) FoundingDate datetime Position PositionID int Name varchar(50) CreationDate datetime

  • Answer:

    CREATE PROCEDURE EmployeeUpdate @Name varchar(50), @EmailAddress varchar(250), @PositionID int AS BEGIN UPDATE Employee SET PositionID = @PositionID WHERE [Name] = @Name AND EmailAddress = @EmailAddress END The preceding code does not have any error handling and assumes that Name and EmailAddress will always exist, so be sure and check for that in your program before running the procedure.

jordan at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.