Alter Column Question

  • Each day I import a text file into SQL Server 2000, v7.0 from Unix. I would like to know how to change the datatype from char/text to datetime?

    Bill Camp

  • From BOL:

    ALTER TABLE table

    { [ ALTER COLUMN column_name

        { new_data_type [ ( precision [ , scale ] ) ]

            [ COLLATE < collation_name > ]

            [ NULL | NOT NULL ]

            | {ADD | DROP } ROWGUIDCOL }

        ]

        | ADD

            { [ < column_definition > ]

            |  column_name AS computed_column_expression

            } [ ,...n ]

        | [ WITH CHECK | WITH NOCHECK ] ADD

            { < table_constraint > } [ ,...n ]

        | DROP

            { [ CONSTRAINT ] constraint_name

                | COLUMN column } [ ,...n ]

        | { CHECK | NOCHECK } CONSTRAINT

            { ALL | constraint_name [ ,...n ] }

        | { ENABLE | DISABLE } TRIGGER

            { ALL | trigger_name [ ,...n ] }

    }

     

    mom

  • Use ISDATE function in order to see if the format is correct,k and then use CONVERT

  • Is this text formated for parsing out fields?

    If so, use convert or cast for each field type.

    ISDATE and other functions can be found at microsoft.com (developers SQL manual)


    Regards,

    Coach James

  • Hi, I have a problem I want UPDATE a column of name "alumnokey" of type "int" to "int identity(1,1) primary key", when i want do the change, show me error. Someone know how can change the properties of this column, please.

    Thanks.

Viewing 5 posts - 1 through 4 (of 4 total)

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