How to insert date in to particular table using csv format file

  • Hi guys,

    I am facing some problem while inserting the date in to particular table using csv format file

    Can anyone help me out.

  • It's going to take more info than that to help you.... As in - what issue are you running into? What does you data look like? What do you want the output to look like?

    Help us help you.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • - What statement are you using ?

    did you test using :

    BULK INSERT mydb.myschema.myobject

    from '\\UNC_path\myobjectdata.txt'

    WITH

    ( FIELDTERMINATOR = ''

    --,CODEPAGE = 'raw'

    , FIRSTROW = 2

    )

    (Check bol for more info)

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Is the column you are inserting into smalldatetime or datetime? Are you getting an overflow error? I have seen problems because of bad dates in legacy systems like 1/1/0007 which will overflow smalldatetime and datetime.

    As Matt said, without more information about your problem I can't provide anymore help.

  • Check OPENROWSET, OpenDataSource help.

    It may help you.

  • You can use Import Data feature to insert data from csv file to a table. In the Data Source. You have to choose "Text File" from the dropdown list. If you use the table name as your csv filename, you even do not need to change the Destination table name.

    --------------------------------------------------------------
    DBA or SQL Programmer? Who Knows. :unsure:

  • Often we have problems with American date formats vs ISO formats vs rest of world formats 🙂 (we in Australia use dd/mm/yyyy). Check which format you're using. You could always treat the column as a string column, get the data into some temporary/scratch/staging table and then use some string manipulation or appropriate convert statements to get the date.

  • OP has "left the building"... 😛

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 8 posts - 1 through 7 (of 7 total)

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