how to change coloumn (varchar to datetime)

  • i have a table in which one coloumn is varchar(30) but it contains

    dates in a format 30.08.2002 i want to make that coloumn to datetime

    but when am changing that it is giving a error like

    Unable to modify table.

    ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error

    converting datetime from character string.

    what should i do to change the coloumn from varchar to datetime

  • you will have to rename the table. Drop constraints.

    Create your new table with the correct datatype and then populate the data back in form the renamed table, Using a convert statement on your changed column.

    Simon Sabin

    Co-author of SQL Server 2000 XML Distilled

    http://www.amazon.co.uk/exec/obidos/ASIN/1904347088


    Simon Sabin
    SQL Server MVP

    http://sqlblogcasts.com/blogs/simons

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply