Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

Store Procedure in SQL??

Can you take a look at this and see if this is correct?

Say I have two tables like this:

People(pid,name,eid) pid is PK, auto increment
Employee(eid,type) pid is pk, auto increment

Store Procedure for creating new employee:

CREATE PROCEDURE [dbo].[CreateNewEmployee]
@name varchar(255),
@type varchar(10),
@NewID int OUT

AS
declare @tmpid int
INSERT INTO Employee(type)VALUES(@type)
SET @tmpid = SCOPE_IDENTITY()
GO

INSERT INTO People(name,eid)VALUES(@name,@tmpid)
SET @NewID = SCOPE_IDENTITY()
Go


IS this correct??
ASKER CERTIFIED SOLUTION
Avatar of dqmq
dqmq
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial