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

syntax for copy command

priyan
P: 54
hai everybody,
I need to copy data from a text file to a table i used copy command
like this
Expand|Select|Wrap|Line Numbers
  1.  
  2. copy city from 'e\ccccc.txt' with delimiter as ','
  3.  
it worked successfully. But now i need to copy a data from a text file which is in my system to the database in server..

path of the file in my system is
Expand|Select|Wrap|Line Numbers
  1. \\ttcpl2\e\ccccc.txt
  2.  
if use copy command like this
Expand|Select|Wrap|Line Numbers
  1. copy city from '\\Ttcpl2\e\ccccc.txt' with delimiter as ','
  2.  
I got an error
Expand|Select|Wrap|Line Numbers
  1. WARNING:  nonstandard use of \\ in a string literal
  2. LINE 1: copy city from '\\Ttcpl2\e\ccccc.txt' with delimiter as ','
  3.                        ^
  4. HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
  5.  
  6. ERROR: could not open file "\Ttcpl2eccccc.txt" for reading: No such file or directory
  7. SQL state: 58P01
  8.  
  9.  
If i use /copy command
Expand|Select|Wrap|Line Numbers
  1. \COPY city FROM '\\ttcpl2\e\ccccc.txt '  WITH DELIMITER  ',' 
  2.  
Expand|Select|Wrap|Line Numbers
  1. ERROR: syntax error at or near "\"
  2. SQL state: 42601
  3. Character: 1
  4.  
Please help me as soon as possible..........
Aug 14 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 534
Try either to double the backslashes (use \\\\ instead of \\) or replace them with forward-slashes, that is use "/" in place of "\"
Aug 14 '07 #2

priyan
P: 54
hai everybody,
I need to copy data from a text file to a table i used copy command
like this
Expand|Select|Wrap|Line Numbers
  1.  
  2. copy city from 'e\ccccc.txt' with delimiter as ','
  3.  
it worked successfully. But now i need to copy a data from a text file which is in my system to the database in server..

path of the file in my system is
Expand|Select|Wrap|Line Numbers
  1. \\ttcpl2\e\ccccc.txt
  2.  
if use copy command like this
Expand|Select|Wrap|Line Numbers
  1. copy city from '\\Ttcpl2\e\ccccc.txt' with delimiter as ','
  2.  
I got an error
Expand|Select|Wrap|Line Numbers
  1. WARNING:  nonstandard use of \\ in a string literal
  2. LINE 1: copy city from '\\Ttcpl2\e\ccccc.txt' with delimiter as ','
  3.                        ^
  4. HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
  5.  
  6. ERROR: could not open file "\Ttcpl2eccccc.txt" for reading: No such file or directory
  7. SQL state: 58P01
  8.  
  9.  
If i use /copy command
Expand|Select|Wrap|Line Numbers
  1. \COPY city FROM '\\ttcpl2\e\ccccc.txt '  WITH DELIMITER  ',' 
  2.  
Expand|Select|Wrap|Line Numbers
  1. ERROR: syntax error at or near "\"
  2. SQL state: 42601
  3. Character: 1
  4.  
Please help me as soon as possible..........

i have did as if u have said
Expand|Select|Wrap|Line Numbers
  1. \COPY city FROM '//ttcpl2/e/ccccc.txt '  WITH DELIMITER  ',';
  2.  
Expand|Select|Wrap|Line Numbers
  1. ERROR: syntax error at or near "\"
  2. SQL state: 42601
  3. Character: 1
  4.  
  5.  
Aug 15 '07 #3

Expert 100+
P: 534
i have did as if u have said
Expand|Select|Wrap|Line Numbers
  1. \COPY city FROM '//ttcpl2/e/ccccc.txt '  WITH DELIMITER  ',';
  2.  
Expand|Select|Wrap|Line Numbers
  1. ERROR: syntax error at or near "\"
  2. SQL state: 42601
  3. Character: 1
  4.  
Why do you have a backslash at the beginning of your command?
Aug 15 '07 #4

Post your reply

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