I need to insert a string (a comment) which should include a date. What I need is basically the following simple operation:
INSERT INTO [Table_1]
([textColumn])
VALUES
('Date: ' + GETDATE())
GO
This however, returns the following error: Conversion failed when converting date and/or time from character string.
Any quick fixes?
what is the date time format you need?
select one from here http://www.sql-server-helper.com/tips/date-formats.aspx and convert it to a char as bellow
INSERT INTO [Table_1]
([textColumn])
VALUES
('Date: ' +CONVERT(CHAR(10), GETDATE(), 120))
GO