I have written a very simple stored proc to insert a record into a table =
and to return the value of the identity column that has been created by =
SQL. I have done this dozens of times in SQL 7. For some reason, I get =
a syntax error with what I have done. Below is the Table design and the =
stored proc. Please let me know what I have done wrong. =20
Thanks!!
David Burt
############ Table Structure ############ =20
CREATE TABLE [dbo].[tblEmployees] (
[EmpID] [int] IDENTITY (1, 1) NOT NULL ,
[SSN] [nchar] (9) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[FName] [nvarchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[MName] [nvarchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[LName] [nvarchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[HireDate] [datetime] NULL ,
[TerminateDate] [datetime] NULL=20
) ON [PRIMARY]
GO
############ Stored Procedure ############ =20
CREATE PROCEDURE spAddEmplooyee=20
@SSN nchar(9),
@FName nvarchar(25),
@MName nvarchar(25),
@LName nvarchar(25),
@HireDate datetime,
@TerminateDate datetime,
@EmpID int OUTPUT
AS=20
/* Create New Record */
INSERT INTO tblEmployees {
SSN, FName, MName, LName, HireDate, TerminateDate
}
VALUES {
@SSN, @FName, @MName, @LName, @HireDate, @TerminateDate
}
/* Store the identity value from the newly inserted record into our =
ouput variable */
SELECT @EmpID =3D @@IDENTITY
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists