Newbie Question on Stored Procedures
I am trying to write a stored procedure that receives data passed from a web page and generates some data within itself. I'm not having a lot of success so far. I want to pass 5 variables into the procedure and insert them, along with one that I populate when the procedure runs, into the table. This is what I have so far:
CREATE PROCEDURE dbo.ADD_NEW_DETAIL
@title varchar,
@type varchar,
@summary nvarchar,
@desc_text nvarchar,
@status varchar
AS
DECLARE @detail_id int
SELECT @detail_id = MAX(DETAIL_ID) FROM TICKET_DETAIL + 1
INSERT INTO TICKET_DETAIL (DETAIL_ID,TITLE,TYPE,SUMMARY,DESC_TEXT,STATUS)
VALUES (@detail_id,@title,@type,@summary,@desc_text,@status)
GO
I realize that my select statement doesn't work, but I'm not sure what the syntax should be. Do I have to specify the size/length of the incoming variables?
Thanks for the help.
[1002 byte] By [
Broodmdh] at [2007-11-19 18:40:20]

# 1 Re: Newbie Question on Stored Procedures
Dear Broodmdh,
Here below is your correct store procedure:
CREATE PROCEDURE dbo.ADD_NEW_DETAIL
@title varchar,
@type varchar,
@summary nvarchar,
@desc_text nvarchar,
@status varchar
AS
DECLARE @detail_id int
SET @detail_id = ISNULL((SELECT MAX(DETAIL_ID) FROM TICKET_DETAIL), 0) + 1
INSERT INTO TICKET_DETAIL (DETAIL_ID,TITLE,TYPE,SUMMARY,DESC_TEXT,STATUS)
VALUES (@detail_id,@title,@type,@summary,@desc_text,@status)
GO
ITGURU at 2007-11-10 3:30:30 >
