December 21, 2015 at 12:47 pm
I am inserting some data from a self join CTE into a table. When i do select * into to load data into that table it works fine. But when i use insert into, it returns 'Conversion failed when converting date and/or time from character string' error. My source and destination columns related to date are both declared as datetime.
December 21, 2015 at 12:53 pm
s.kandepi3 (12/21/2015)
I am inserting some data from a self join CTE into a table. When i do select * into to load data into that table it works fine. But when i use insert into, it returns 'Conversion failed when converting date and/or time from character string' error. My source and destination columns related to date are both declared as datetime.
Can you provide any actual information here? Things like table definitions, the code you are using, sample data etc. Without this information nobody can do anything but guess. Take a look at this article for the kinds of information you need to be posting. http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/[/url]
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
December 21, 2015 at 12:54 pm
s.kandepi3 (12/21/2015)
I am inserting some data from a self join CTE into a table. When i do select * into to load data into that table it works fine. But when i use insert into, it returns 'Conversion failed when converting date and/or time from character string' error. My source and destination columns related to date are both declared as datetime.
If both source and target are datetime, I cannot see how you would ever get this error. Unless you are doing something to affect datatypes in your CTE.
So please post the CTE, showing how the offending column is being used.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
December 21, 2015 at 4:21 pm
From the error, you're doing something with a string column, but without DDL for the tables and the CTE, anything I say would be a guess.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply