| Author |
Topic |
|
KidSQL
Yak Posting Veteran
88 Posts |
Posted - 2005-06-02 : 09:42:59
|
| It's my first time doing this, so if anyone could provide me with guidance, I would appreciate it.I have a very simple temporary table called #test which I am trying to export as a tab-delimited text file. However, I get various error messages when I do this and whose meanings are cryptic to me.I am using:bcp #test out c:\test.txt -c -T(note that at the moment I don't really care about the format, I would be happy just being successful at exporting).However, I get this error:Server: Msg 179, Level 15, State 1, Line 1Cannot use the OUTPUT option when passing a constant to a stored procedure. I get the same error message when using a permanent table and specifyingbcp database.owner.mytable out c:\test.txtCan anyone point me in the right direction, please?Thank you. |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
|
|
KidSQL
Yak Posting Veteran
88 Posts |
Posted - 2005-06-02 : 09:49:09
|
| Hi, thanks for this response. However, I get the same thing when working with permanent tables. Any ideas? |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-06-02 : 09:53:55
|
| You are running this from the command line aren't you ? That looks like a Query Analyzer message.Try the helper app.DamianIta erat quando hic adveni. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-02 : 09:58:49
|
| To run bcp from Query Analyser, use thisExec master..xp_cmdShell 'bcp "select * from DBname..#test" queryout "C:\text.txt" -c'MadhivananFailing to plan is Planning to fail |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-06-02 : 10:00:35
|
| Still won't work. #test isn't available in bcp's context.DamianIta erat quando hic adveni. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-06-02 : 10:02:06
|
quote: Originally posted by madhivanan To run bcp from Query Analyser, use thisExec master..xp_cmdShell 'bcp "select * from DBname..#test" queryout "C:\text.txt" -c'MadhivananFailing to plan is Planning to fail
I don't think that'll work....Can you describe to us how your temp table is being created?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-06-02 : 10:03:05
|
You gotta be quick today Brett DamianIta erat quando hic adveni. |
 |
|
|
KidSQL
Yak Posting Veteran
88 Posts |
Posted - 2005-06-02 : 10:05:32
|
| Yes, it's one part of a large query. I suppose I can create a 'permanent' table (although I'd rather not), but I do need to run something like this from Query Analyzer (Thanks Merkin, that was my problem, by the way...yes I am a git).Any ideas on how to do this with a temp table? If not, should I go perm and use the same line that madhivanan kindly suggested? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-03 : 00:36:29
|
| Move the result set to temporary table and run bcp from Query Analyser and drop that tableMadhivananFailing to plan is Planning to fail |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-06-03 : 01:27:39
|
| How many times do you need to be told that won't work Madhivanan ?DamianIta erat quando hic adveni. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-03 : 02:03:53
|
quote: Originally posted by Merkin How many times do you need to be told that won't work Madhivanan ?DamianIta erat quando hic adveni.
Merkin, Actually I meantSelect * into mytemptable from (Large Query) TExec master..xp_cmdShell 'bcp "Select * from DBname..mytemptable" queryout "C:\testing.txt" -c'Drop table mytemptableAm I missing something?MadhivananFailing to plan is Planning to fail |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-06-03 : 02:13:11
|
| That isn't a temporary table, so your use of language was misleading.DamianIta erat quando hic adveni. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-03 : 02:25:53
|
Yes You are correct Merkin. Still I have to learn more. Thanks for pointing that MadhivananFailing to plan is Planning to fail |
 |
|
|
|