Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

converting timestamp to datetime

Posted on 2006-10-27
7
Medium Priority
?
1,289 Views
Last Modified: 2012-05-11
I have collumn data with timestamp value, and when i try to insert into datetime column, its throwing error as:

Msg 260, Level 16, State 1, Server SYS_034, Procedure TD_History, Line 17
Disallowed implicit conversion from data type datetime to data type timestamp, table 'MASTER.dbo.AUD_History', column 'DateRealisation'. Use the CONVERT function to run this query.

hOPE you will have immed solution.

Thanks in adv..
~ HNS ~
0
Comment
Question by:homnath_sharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 100 total points
ID: 17818671
A timestamp column in SQL Server has nothing to do with date or time, this is more like a sequential number rather than a datetime value
0
 

Author Comment

by:homnath_sharma
ID: 17818880
Aneesh,

I need to insert datetime column data of one table into  timestamp column field in another table.

Regds.
~ HNS ~
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17818895
You dont have to specify the value in the Timestamp column explicitly, it will be inserted/modified automatically with the insert/update operation
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:homnath_sharma
ID: 17818925

See,

I am trying to insert value at runtime thru trigger as below:

create trigger hist
on DBO.XXX_History
instead of delete
as
begin
INSERT INTO DBO.AUD_History SELECT d.DateRealisation from deleted d.
end

AUD_History.DateRealisation is of type (timestamp)
XXX_History.DateRealisation is of type (datetime)

Error is as:
Disallowed implicit conversion from data type datetime to data type timestamp, table 'Expert.dbo.AUD_History', column 'DateRealisation'. Use the CONVERT function to run this query.


Regd.s
~ HNS ~
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17819807
can you post the table structure
0
 
LVL 16

Expert Comment

by:TSmooth
ID: 17820021
I think you're going to have to change your data structure to change the data type of that field or add an additional field. From SQL Books Online:

"The SQL Server timestamp data type has nothing to do with times or dates. SQL Server timestamps are binary numbers that indicate the relative sequence in which data modifications took place in a database. The timestamp data type was originally implemented to support the SQL Server recovery algorithms."

"Never use timestamp columns in keys, especially primary keys, because the timestamp value changes every time the row is modified."

Why is AUD_History.DateRealisation of type timestamp?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17945886
Thanks for Grace "C"
Hope you need to go thru the User terms and conditions
http://www.experts-exchange.com/help.jsp#hi73
http://www.experts-exchange.com/help.jsp#hi18
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
What we learned in Webroot's webinar on multi-vector protection.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question