Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Dovinshka
Starting Member
6 Posts |
Posted - 2006-01-10 : 22:07:43
|
| Hi,I need to be able to export from an existing database, all fields with a certain column id. I have been pointed in the direction of bcp, however I am having difficulty finding the right syntax.Thanks,D.(P.S. MSSQL 2000 Server) |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-10 : 22:18:56
|
| from SQLServer Books OnLine on bcp UtilitySyntaxbcp {[[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]"]Example :bcp "Northwind.Jane Doe.Jane's Orders" out "Jane's Orders.txt" -c -q -U"Jane Doe" -P"go dba"-----------------'KH' |
 |
|
|
Dovinshka
Starting Member
6 Posts |
Posted - 2006-01-10 : 22:45:16
|
| Hi Khtan,Yeah I did see that part of the syntax. I'm just a little lost specifying the column name. Tables have a 'fse_id' column to specify what belongs to whom. I can see bcp "dbname.Jane Doe.Jane's Orders" out "Jane's Orders.txt" -c -q -U"user" -P"pass"and out of all those command switches, I don't see what to use to specify where column = "fse_id"Thanks,D. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-10 : 22:56:56
|
| if you need to specify which column to BCP out, use the queryoutbcp "select col1, col2, .. from dbname..tblname" QUERYOUT ....-----------------'KH' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-12 : 00:23:50
|
| TryEXEC Master..xm_cmdShell 'bcp "Select columns from DBname..tableName" queryout "C:\result.txt" -c'MadhivananFailing to plan is Planning to fail |
 |
|
|
Dovinshka
Starting Member
6 Posts |
Posted - 2006-01-12 : 21:35:07
|
| Thanks for that guys. I will give it a shot. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|