Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i try to insert to column "timestamp" a value as "Datetime.now"
but i got sql exception :
Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.

please help
Posted
Comments
[no name] 19-Aug-14 21:09pm    
Okay.... a timestamp is an auto generating value. So why are you trying to set the value of the column? Are you sure that using a timestamp is the right choice for what you are doing? What exactly are we supposed to help you with?
Member 10631195 19-Aug-14 21:13pm    
i wont enter date to my table what type to use ?
Member 10631195 19-Aug-14 21:13pm    
to order result by date
[no name] 19-Aug-14 21:18pm    
Personally, I would use a DateTime but not knowing anything at all about your project I would have no idea what you should be using.
ChauhanAjay 19-Aug-14 21:15pm    
You want to enter the into your table? If yes then create a column with datatype datetime and you can insert your date into it.

Just add more information about timestamp field:

Quote:
A table can have only one timestamp column. The value in the timestamp column is updated every time a row containing a timestamp column is inserted or updated. This property makes a timestamp column a poor candidate for keys, especially primary keys. Any update made to the row changes the timestamp value, thereby changing the key value. If the column is in a primary key, the old key value is no longer valid, and foreign keys referencing the old value are no longer valid. If the table is referenced in a dynamic cursor, all updates change the position of the rows in the cursor. If the column is in an index key, all updates to the data row also generate updates of the index.


Read more:
http://technet.microsoft.com/en-us/library/aa260631%28v=sql.80%29.aspx[^]
 
Share this answer
 
You can't insert the values into timestamp column explicitly. It is auto-generated. Don't use this column in your insert statement. If you want to manually manage your column then change its datatype to datetime. To know more about timestamp visit http://msdn.microsoft.com/en-us/library/ms182776(SQL.90).aspx[^]. Microsoft does not recommend using timestamp.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900