Re: Syntax error converting character string to datetime

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Aaron Bertrand - MVP (aaron_at_TRASHaspfaq.com)
Date: 05/28/04


Date: Fri, 28 May 2004 10:02:44 -0400


> I need to transfer data from our legacy system to SQL
> server. But I got a error message when converting a
> character field to date type with data like '20020401'.

The suspicious word here is "like" ... this is one of the problems for
choosing a character column to store date (which is usually done so the user
can prettify the display in Enterprise Manager and see the date "stored" the
way they want them to be displayed).

You probably have one or more values in the column that is NOT a date.

SELECT COUNT(*) FROM SourceTable WHERE IsDate(column) = 0

-- 
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


Relevant Pages

  • Re: Using a character GUID for the primary key - Any issues to know ab
    ... > We are about to begin a large development effort using .Net and SQL ... > or a character field that contains a GUID (36 long character field ... I know SQL Server has a ... > value in a clustered index? ...
    (microsoft.public.sqlserver.server)
  • RE: Fulltext failure on a 2 node cluster
    ... Server full-text search resource online: "SQL Cluster Resource 'Full Text' ...
    (microsoft.public.sqlserver.clustering)
  • Re: HELP PLEASE ~ ???
    ... You mentioned that it went ahead and added a SQL ... SQL Server 2000 database for all my data. ... find the connectionString in the newly recreated SQLExpress database. ... The connection string specifies a local Sql Server Express instance ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Multi-Channel Raid VS SAN Storage
    ... A 5~6 years old server is a very old server. ... As I mentioned, the server is one node in a cluster environment, and SQL is ... We actually are running RAID 1+0 and our aplication is definately more ... needs it's own SAN device, or at least a dedicated IO channel on the SAN. ...
    (microsoft.public.sqlserver.setup)
  • RE: How do I get back to base SQL server on my SBS 2003 server?
    ... After you uninstall SQL 2005, the instance which you upgraded will not go ... Uninstall and then reinstall ISA server. ... Uninstall and then reinstall the Monitoring component. ... Tools to Maintenance, change Monitoring component to Install, and then ...
    (microsoft.public.windows.server.sbs)