|
-
May 3rd, 2007, 04:26 AM
#1
Thread Starter
Fanatic Member
[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.
-
May 3rd, 2007, 12:04 PM
#2
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"|"
-
May 9th, 2007, 09:15 PM
#3
Thread Starter
Fanatic Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|