By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

How to use Copy Command in a loop?

P: 6
hi,

[COPY worktrainees_history FROM E'C:\\bcp\\worktrainees_history.txt' USING DELIMITERS ',' CSV]

the above command is working fine but i have more than 100 tables and related text files i wanted to run in a loop but
when i use a parameter for table name it is giving error so can any one give me example for this
Feb 4 '11 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 700
Write a script to do that.
Feb 4 '11 #2

P: 6
can you give sample script i dont know how to do that
Feb 28 '11 #3

Expert 100+
P: 700
In linux
Expand|Select|Wrap|Line Numbers
  1. for i in <list of tables>;
  2. do
  3. psql <database and user parameters> -c "COPY ${i} FROM E'C:\\bcp\\${i}.txt' USING DELIMITERS ',' CSV" 
  4.  
Probably under windows you sould be able to do that in similar way, but I'm not a windows expert.
Mar 13 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.