SQL Server: Cannot insert an explicit value into a timestamp column
According to MSDN, timestamp
Is a data type that exposes automatically generated, unique binary
numbers within a database. timestamp is generally used as a mechanism
for version-stamping table rows. The storage size is 8 bytes. The
timestamp data type is just an incrementing number and does not
preserve a date or a time. To record a date or time, use a datetime
data type.
You're probably looking for the datetime
data type instead.
SQLAlchemy fails to insert timestamp into MSSQL
So, thanks to these fine gentleman out there @LaugingVergil and @HaleemurAli I've just decided to add another sed
hack to my dockerfile...
I just do RUN sed -i 's/TIMESTAMP/DateTime/g' /usr/lib/python3.4/site-packages/luigi/db_task_history.py
before CMD /usr/bin/luigid
Get inserted timestamp
The problem is that TIMESTAMP is a data type that is automatically generated and only exposed as read-only. It's based around an incrementing number within the system.
SQL Server: Cannot insert an explicit value into a timestamp column
Try this:
DECLARE @table TABLE(id INT, val TIMESTAMP NOT NULL)
DECLARE @table2 TABLE(val DATETIME)
INSERT @table (id)
OUTPUT inserted.val INTO @table2(val)
VALUES (1)
SELECT
t.id,
t.val,
CONVERT( TIMESTAMP, t2.val ) AS table2_timestamp
FROM
@table AS t,
@table2 AS t2
Related Topics
How to Cast a String to Integer and Have 0 in Case of Error in the Cast with Postgresql
Postgresql: Insert into ... (Select * ...)
Linux Python3 - Can't Open Lib 'SQL Server'
How to Do If Not Exists in SQLite
How to Show Row Numbers in Postgresql Query
How to Correctly Insert Newline in Nvarchar
Ssis Source Format Implicit Conversion for Datetime
Improving Performance of Cluster Index Guid Primary Key
SQL Select to Get the First N Positive Integers
Split One Column Value into Multiple Column Values
How to Find Third or Nᵗʰ Maximum Salary from Salary Table
How to See the Values of a Table Variable at Debug Time in T-Sql
Query a Database Based on Result of Query from Another Database
How to Select Records with Maximum Values in Two Columns