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(@na me,@tmpid)
SET @NewID = SCOPE_IDENTITY()
Go
IS this 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(@na
SET @NewID = SCOPE_IDENTITY()
Go
IS this correct??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.