How to insert only time data from the txt (delimited) file into database table

  • HI,

    I am using BULK INSERT from file "|" delimited. First column is date without time and it is all right because in table column datetime time is 00:00:00, but second column should be only time.

    Here is command BULK INSERT which I use an I would like suggestion how to change it to get what I need:

    string sqls="BULK INSERT table_LOG FROM '"+File_Name+"' WITH"+

    "(MAXERRORS = 0,"+

    "FIELDTERMINATOR = '|',"+

    "ROWTERMINATOR = '\n')";

    (Note:SQL command in C#):

    Content of txt file is like this:

    03/04/2004|162931|04904162931|00|00001|001|S|0000|0000|00001

    03/04/2004|162934|04904162931|00|00001|001|X|0003|0003|00000

    03/04/2004|162934|05304162927|00|00001|002| |0007|0007|00008

    Another thing is the last column which if I format as char there is problem with "square" mark what can be seen in colum using Enterprise Manager.

  • One option may be to store the timecolumn as an int.

    The 'square' mark you're talking about is most likely some end-of-row unprintable charachter. Make sure that EOL tokens are what you expect them to be in you bulk statement.

    /Kenneth

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

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