I have a three tier system, SQL Server backend, hand written data access layer, and using stored procedures.
I have a table called EventTable. Each row is an 'Event'. An Event has a primary key, and a start date.
CREATE TABLE EventTable
(
ID INT IDENTITY(100,1) PRIMARY KEY,
StartTime DateTime NOT NULL
)
There is a stored procedure called EventTable_Create. Incidentally, is the create method okay as written?
CREATE PROCEDURE Event_Create
@NewID INT OUT
AS
DECLARE @START DATETIME
SELECT @START = getdate()
INSERT INTO EventTable VALUES(@START, NULL)
SELECT @NewID = MAX(ID) FROM EventTable
GO
The data access layer returns an int to the caller, but should it instead return an instance of a data transfer object called Event? If that is true, should I be returning both the newly created ID and start time as well, so that the data access layer can create the event transfer object?