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 2005 Forums
 Other SQL Server Topics (2005)
 BCP export

Author  Topic 

pseudo
Starting Member

2 Posts

Posted - 2007-04-17 : 08:41:30
I would just like to know if anyone has any advice on my problem. On our database we do various exports to text files each day with the bcp utility. With each of the exports, all our data is read into a ##temptable, and dropped afterwards. One of the stored procedures keeps failing with an error that sayas columns can't be skipped when using the BCP utility, but the temptable only has one column(DATA) and that is the only one selected.

This happens only the first time it is executed in a given session, the second time the data usually exports fine(although I did encounter times when I have to execute it 3-4 times before it runs through). The bcp call is part of a stored procedure that is called from a job and directly in sql server, and it does the same in both counts. Any advice would be appreciated.

bpgupta
Yak Posting Veteran

75 Posts

Posted - 2007-04-17 : 08:45:27
Which sql server version u r using , please post your statement inside the SP .
Go to Top of Page

pseudo
Starting Member

2 Posts

Posted - 2007-04-17 : 08:52:43
It is sql server 2005 with service pack 2

the command is as follows

--lets Get the date and insert it
set @BCPCOMMAND = 'bcp "select DATA from tempdb.dbo.##FACSDATA" queryout '

--Construct the Bcp Command and execute it
set @BCPCOMMAND = @BCPCOMMAND + @FILEPATH + ' -T -c'

exec @BCPRESPONSE = MASTER..xp_cmdshell @BCPCOMMAND
Go to Top of Page
   

- Advertisement -