Results 1 to 3 of 3

Thread: [RESOLVED] BCP program [MSSQL 2000]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Resolved [RESOLVED] BCP program [MSSQL 2000]

    i use this line in command prompt
    BCP "SELECT * FROM Table1..Users" queryout "C:\file1.txt" -T -N

    it use 'weird' character as field separator

    i wonder if it can use '|' as separator?

    i already read BOL but still can't understand completely how it done..

    also can BCP be used using SQL DMO?

    thanks,

    erick
    Last edited by erickwidya; May 9th, 2007 at 09:17 PM.

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: BCP program [MSSQL 2000]

    The default field separator is a Tab. Use the -t argument to change the field separator.

    BCP "SELECT * FROM Table1..Users" queryout "C:\file1.txt" -T -N -t"|"

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: BCP program [MSSQL 2000]

    thx brucevde
    sorry for late reply..i didn't notice it must use -t for field separator..

    i manage to do it and do the insert back from text file to table using BULK INSERT

    here's the code

    Code:
    -- using query to specified selected data
    BCP "SELECT * FROM DBNAME..TABLENAME" queryout "C:\FILENAME.txt" -T -w -k -t"|"
    Code:
    -- insert to a table from a file
    BULK INSERT DBNAME..TABLENAME
    FROM 'C:\FILENAME.txt'
    WITH 
    (
      FIELDTERMINATOR = '|',
      ROWTERMINATOR = '\n',
      DATAFILETYPE = 'widechar',
      KEEPNULLS
    )
    thanks again,
    erick

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

Posting Permissions

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



Click Here to Expand Forum to Full Width