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 |
|
trackjunkie
Starting Member
31 Posts |
Posted - 2010-01-08 : 15:31:38
|
| I have a simple table with one row containing two values. I'm trying to use a bcp command to outout the contents of that row to a .csv file. I want the file to be created by the stored proceddure at runtime. I have:SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER Procedure [dbo].[Flex_CreateCSV] ASBEGINdeclare @sql varchar(8000)select @sql = 'bcp FlexApp.Flex_DataWatchTable.* format D:\Temp\LabelPrintEvent.csv -c -t -T -S' + @@servername exec master..xp_cmdshell @sqlENDWhen I execute I get: "An error occured while proicessing to command line."There is not other information. Can anyone see what I did wrong?This is my first stab at a bcp, so I imagine it could be a lot of things. |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2010-01-08 : 15:58:40
|
| If you replace + @@servername with the actual server name does it run ok?EDIT: Also it lookes liek you forgot a space-select @sql = 'bcp FlexApp.Flex_DataWatchTable.* format D:\Temp\LabelPrintEvent.csv -c -t -T -S ' + @@servername After the -S |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-08 : 16:00:25
|
SET @SqlCmd = 'bcp "SELECT * FROM database.schema.table" queryout "D:\Temp\LabelPrintEvent.csv " -c -T'; No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|