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.
| Author |
Topic |
|
new_tosql
Starting Member
17 Posts |
Posted - 2008-03-27 : 10:01:20
|
| Hi,Can we insert the data from #temp table to csv file using bcp in sql server ?I really appreciate if anyone can answer me this or any workarounds for this. Thanks in advance, |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-03-27 : 10:31:33
|
| Nope - bcp uses a new connection so can't access the temp table.Workarounds are to use a permanent table or global temp table.These can either use a spid as identifier for the rows and filter on that in the bcp or include the spid in the table name.I will often have a table with a single column (plus the spid/batch number and sequence) and format the row in that table and bcp out the single column using the batch and sequence.seehttp://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
new_tosql
Starting Member
17 Posts |
Posted - 2008-03-27 : 11:18:19
|
| I am using global temp table .Now i am able to create the csv output file but not sending any data in to it. Could you please help me with that.Thanks |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-03-27 : 11:38:50
|
| Is there any data in the global temp table?Can you post the bcp command.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|