I have this SQL statement
INSERT housingSurvey ([nameID], [houseID], [jobID], [Active], [comment], [needsMaintenance], [lastUpdateDate)
VALUES (@NAMEID, @HOUSEID, @JOBID, 1, @DUEDATE, @COMMENT, NULL, @LASTUPDATEDATE)
I tried this stored procedure, but I don't get the current date.
CREATE PROCEDURE housingSurveyS(
@NAMEID INT,
@HOUSEID INT,
@JOBID INT,
@COMMENT BIT,
@DUEDATE NVARCHAR,
CURRENTTIME)
AS
BEGIN
INSERT INTO housingSurvey(
[nameID],
[houseID],
[jobID],
[Active],
[comment],
[dueDate],
[needsMaintenance],
[lastupdatedate])
VALUES (
@NAMEID,
@HOUSEID,
@JOBID,
1,
@COMMENT,
@DUEDATE,
NULL,
@LASTUPDATEDATE)
END
Could you please take a look at what I did wrong. Thanks
UPDATE I changed it CURRENTTIME to DATETIME as parameter to insert current date to [lastupdatedate]... it still doesn't work...
VALUES (
...
@DUEDATE,
@COMMENT
Are in the wrong order when related to the order of fields defined in the INSERTs statements field list, switch them around.
Edit
CREATE PROCEDURE housingSurveyS(
@NAMEID INT,
@HOUSEID INT,
@JOBID INT,
@COMMENT BIT,
@DUEDATE NVARCHAR(32) --add a size, should this be DATETIME
)
AS
BEGIN
INSERT INTO housingSurvey(
[nameID],
[houseID],
[jobID],
[Active],
[comment],
[dueDate],
[needsMaintenance],
[lastupdatedate]
) VALUES (
@NAMEID,
@HOUSEID,
@JOBID,
1,
@COMMENT,
@DUEDATE,
NULL,
GETDATE()
)
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With