Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 bcp export data from global temp table
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tonymartini777
Starting Member

2 Posts

Posted - 02/01/2012 :  12:49:03  Show Profile  Reply with Quote
Hi all,

I'm getting the following error:

SQLState = S0001, NativeError = 0Error=[Microsoft]SQLServer Native Client 10.0]Unable to open BCP host data-file

For the following SQL code:

USE Runtime
GO
CREATE TABLE ##EnergyWeekReport(
Substation nvarchar(50) NOT NULL,
Monday float NULL,
Tuesday float NULL,
Wednesday float NULL,
Thursday float NULL,
Friday float NULL,
Saturday float NULL,
Sunday float NULL,
This_Week float NULL,
Last_Week float NULL);

DECLARE
@Mon float,
@Tue float,
@Wed float,
@Thu float,
@Fri float,
@Sat float,
@Sun float,
@Week float,
@preWeek float,

@dateIN datetime,

@Filename nvarchar(50),
@bcpcmd nvarchar(500);

-- Assign values
SET @dateIN = '2012-1-23';

SET @Mon = dbo.fnSEL_Monday_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @Tue = dbo.fnSEL_Tuesday_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @Wed = dbo.fnSEL_Wednesday_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @Thu = dbo.fnSEL_Thursday_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @Fri = dbo.fnSEL_Friday_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @Sat = dbo.fnSEL_Saturday_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @Sun = dbo.fnSEL_Sunday_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @Week = dbo.fnSEL_WeekTot_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');
SET @preWeek = dbo.fnSEL_preWeekTot_MWh(@dateIN, 'CB02_SS1_351S_1P7_MWh', 'CB02_SS2_351S_1P7_MWh');

INSERT INTO ##EnergyWeekReport
SELECT '138kV Line 1',@Mon, @Tue, @Wed, @Thu, @Fri, @Sat, @Sun, @Week, @preWeek;

SET @bcpcmd = 'bcp "SELECT * FROM ##EnergyWeekReport" queryout c\test.txt -c -T -S ww-historian';
EXEC xp_cmdshell @bcpcmd ;

DROP TABLE ##EnergyWeekReport
GO

I'm running this in management studio on the machine where the database resides. I am logged in as an 'aaAdministrator' with all the god rights needed.

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/01/2012 :  13:04:11  Show Profile  Reply with Quote
is c\test.txt path exists in your machine where db resides?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tonymartini777
Starting Member

2 Posts

Posted - 02/01/2012 :  14:36:20  Show Profile  Reply with Quote
Ugh.. I see my path syntax is incorrect it needs to be c:\test.txt - I was missing the :
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/02/2012 :  10:24:51  Show Profile  Reply with Quote
is it working fine now with changed path?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000