Steven Polka
Steven Polka

Reputation: 5

Stored procedure cannot insert into column name Timestamp

I am trying to write a stored procedure to insert into an email table. In my email table, I have the time-created column named timestamp. I did not know timestamp was a SQL keyword. How would I fix this? Thank you (I don't want to change the column name because I have a lot of SQL statements to edit)

CREATE PROCEDURE [dbo].[btbSe]
    @SenderId int,
    @SqlReceiverId int,
    @EmailSubject varchar(max),
    @EmailBody varchar(max),
    @DateTime varchar(50)
AS
    INSERT INTO Emails (SenderId, ReceiverId, EmailSubject, EmailBody, Timestamp) 
    VALUES (@SenderId, @SqlReceiverId, @EmailSubject, @EmailBody, @DateTime, GETDATE())
    RETURN 0

Upvotes: 0

Views: 92

Answers (1)

Popeye
Popeye

Reputation: 35920

You need to wrap such columns into the double quotes as follows:

..
..
INSERT INTO Emails (SenderId, ReceiverId, EmailSubject, EmailBody, "Timestamp") 
VALUES
..
..

Upvotes: 1

Related Questions