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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 getting error using BCP

Author  Topic 

Clages1
Yak Posting Veteran

69 Posts

Posted - 2006-12-05 : 09:06:48
Hi

using this command in QueryAnalizer

bcp "SELECT TOP 10 * FROM teste.dbo.area" QUERYOUT "area.TXT" -U"sa" -P "teste" -c


i get this error

Line 1: Incorrect syntax near 'QUERYOUT'.

Where is my mistake?

tks

C.lages

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-05 : 10:01:13
BCP is a command-line utility...you can't use it directly in QA.

Try using it in combination with xp_cmdshell.

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

Clages1
Yak Posting Veteran

69 Posts

Posted - 2006-12-05 : 10:08:04
Ok, i Fix it using in QA in this way

Select * into tmparea from (select * from area) T
Exec master..xp_cmdShell 'bcp "Select * from teste.dbo.tmparea" queryout "C:\area.txt" -S Clages1 -U"sa" -P "teste" -c -T'
Drop table tmparea

Works fine now
tks
C.lages
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-05 : 10:11:32
Good! You are runnng BCP form a command line.
But from your code above, why do you copy the content from area table to a temp table, outputting the data from there, and later deleting the temporary table?

Why not do this?
Exec master..xp_cmdShell 'bcp "Select * from teste.dbo.area" queryout "C:\area.txt" -S Clages1 -U"sa" -P "teste" -c -T'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Clages1
Yak Posting Veteran

69 Posts

Posted - 2006-12-05 : 10:28:21
Because this is a demo
i real word in (select * from area)
i can use Views and Complex Querys, etc

just it

C.Lages
Go to Top of Page
   

- Advertisement -