Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I want to transfer old SQL Server data using Excel into SQL Server. It looks like the Import/Export Data application automatically sets most data columns to NVARCHAR(255). I am facing a problem because my one column has to be DATE type, but the data in it looks like 18.08.2000 14:48:15.

So I tried this query: 

SELECT CONVERT(Date, DATE_TIME, 113) FROM someTable

I got the following error:

Msg 9807, Level 16, State 0, Line 1

The input character string does not follow style 113, either change the input character string or use a different style.

How to deal with this error?

1 Answer

0 votes
by (11.7k points)

You can try out the code I have written down below to change data type NVARCHAR to DATETIME:

UPDATE myTable

SET columnName = CONVERT(NVARCHAR(255),CONVERT(SMALLDATETIME, columnName,105))

ALTER TABLE myTable

ALTER COLUMN columnName SMALLDATETIME

If you want to get more insights into SQL, check out this SQL Course from Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer

Browse Categories

...