Showing posts with label base. Show all posts
Showing posts with label base. Show all posts

Thursday, March 22, 2012

Bulk Insert to load, ...?... to unload

To load data from a file into a table, I use :

BULK INSERT Base.Prop.Table
FROM 'Path of file'
WITH (FieldTerminator='_', RowTerminator='_\n')

What's the command to unload a table to a file ?

Somebody must know... help... please...Originally posted by Karolyn
To load data from a file into a table, I use :

BULK INSERT Base.Prop.Table
FROM 'Path of file'
WITH (FieldTerminator='_', RowTerminator='_\n')

What's the command to unload a table to a file ?

Somebody must know... help... please...

y dont u just use a DTS package to do the load and unload?|||I don't want to use DTS packages because :

1) for the loading------------------
- the VB-SQLServer program is installed on lots of PCs*
- each day, these PCs download new files
- it's the name of the files that determines in witch table it must be loaded
- the structure of table can be changed anyday by distance by the program

So if I use DTS packages, I'll have to create or reconstruct the packages
each time the program wants to load datafiles.

2) for the unloading------------------
- each time the program is shut down, it unloads some data from tables
- the list of these tables can be changed anytime
- the data unloaded contains some calculated colums that depends that is different for each user

So if I use DTS packages, I'll have for each PCs users different packages and I don't want to have differences in each databases
(for maintenance ease).

*more than 3000 users in France|||What about bcp?|||I've got to put a special column delimiter
Can I detemine it with Bcp ?|||Originally posted by Karolyn
I've got to put a special column delimiter
Can I detemine it with Bcp ?
Use format file.|||Format file in the bcp command ?|||Originally posted by Karolyn
Format file in the bcp command ?

bcp {[[database_name.][owner].]{table_name | view_name} | "query"}
{in | out | queryout | format} data_file
[-m max_errors] [-f FORMAT_FILE :)] [-e err_file]
[-F first_row] [-L last_row] [-b batch_size]
[-n] [-c] [-w] [-N] [-V (60 | 65 | 70)] [-6]
[-q] [-C code_page] [-t field_term] [-r row_term]
[-i input_file] [-o output_file] [-a packet_size]
[-S server_name[\instance_name]] [-U login_id] [-P password]
[-T] [-v] [-R] [-k] [-E] [-h "hint [,...n]"]|||Mister 4 star Snail... I bow and thank you.|||Originally posted by Karolyn
Mister 4 star Snail... I bow and thank you.

For France I could do anything ;)