Question to Chintamani and other SQL experts - Sajha Mobile
SAJHA MOBILE
Question to Chintamani and other SQL experts
Posts 10 · Viewed 4578 · Go to Last Post
Kalopoolbasi
· Snapshot
Like · Likedby · 0
 Hi guys,

I am supposed to copy the result of a query into a flat file. After looking at your problem/solution, I tried the following:

 

Bcp Select.....From....Where..... out "c:\abc.txt" -c -T

Then I got the error:

Msg 102, Level 15, State 1, Line 12

Incorrect syntax near 'out'.

How should I get it to work?

Thanks

smoothcriminal
· Snapshot
Like · Liked by · 0

You can use Export/Wizard instead.

reverse_engineer
· Snapshot
Like · Liked by · 0

try this syntax:

 

bcp "select * from whatever" queryout c:\authors.txt -c -T

basically i think you need the quotes around your query and not your export file... let me know if that helped

reverse_engineer
· Snapshot
Like · Liked by · 0

try this syntax:

 

bcp "select * from whatever" queryout c:\authors.txt -c -T

basically i think you need the quotes around your query and not your export file... let me know if that helped

Kalopoolbasi
· Snapshot
Like · Liked by · 0
Thank you. i will try that.
Kalopoolbasi
· Snapshot
Like · Liked by · 0

I am copying my query result into a temp table and trying to write the contents of the temp table into a flat file..

When I do:

BCP "#temp_NS_events" queryout c:\abc.txt -c -T

I get the error:

Incorrect syntax error near 'BCP'

rawbee
· Snapshot
Like · Liked by · 0

if you just need to export query result in to text file then just run query as result to file

Query->Result to->reuslt to file

all the best ,

have good weekend

Chintamani
· Snapshot
Like · Liked by · 0

use tempdb

create table playertemp

( playerID varchar(25),

playerFname varchar(25),

playerLname varchar(25),

email varchar(25))

 

insert into playertemp

select * from test.dbo.player  //just use your query over here

 

and then

bcp tempdb.dbo.playertemp out "c:\playertemp.txt" -c -T -SKalopoolbasi

note Kalopoolbasi is the server name

This should work.

 

 

 

Kalopoolbasi
· Snapshot
Like · Liked by · 0

Thanks Chintamani...I will let you know how it went after I try this.

Thank you very much.

smoothcriminal
· Snapshot
Like · Liked by · 0

Why do you have to put  the results in Temp table taking TEMPDB resources. Remember SQL server 2005 uses lot of TempDB resources than SQL 2000. Just use Export/Import wizard and schedule it if you like to.

Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 17 · Viewed 3657 · Likes 3
· Posts 1 · Viewed 123
· Posts 1 · Viewed 80
· Posts 1 · Viewed 66
· Posts 1 · Viewed 63
· Posts 77 · Viewed 18548 · Likes 16
· Posts 1 · Viewed 116
· Posts 1 · Viewed 123
· Posts 1 · Viewed 328
· Posts 1 · Viewed 243



Your Banner Here
Travel Partners
Travel House Nepal