Results 1 to 3 of 3

Thread: ALTER data type

  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Red face Unanswered: ALTER data type

    I have created a table from a text file delimited by comma's. The date within the text file is YYYYMMDD and needs to be stored within a smalldatetime column. Unfortunatley whenever I import the data it errors out. If I import the data into a nvarchar column, it imports correctly and then allows me to change the datatype to smalldatetime(thus giving me the correct format). Is there a way I could run a command pre and post to the import?

    ALTER TABLE PO MODIFY x_column nvarchar

    IMPORT DATA

    ALTER TABLE PO MODIFY x_column smalldatetime

    hope this is clear enough, thanks for the help

  2. #2
    Join Date
    Oct 2001
    Location
    England
    Posts
    426
    alter table tblname alter column colname smalldatetime

    You would be safer importing to a staging table then inserting from there.

  3. #3
    Join Date
    Sep 2003
    Posts
    2
    thanks for the quick response, worked like a charm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •