显示标签为“mssql”的博文。显示所有博文
显示标签为“mssql”的博文。显示所有博文

2012年3月6日星期二

BCP error

Hi,
Env: win2k, mssql 8.00.194, Standard Edition

Please help me to make the following bcp to work.
I want to save RS from store procedure to ascii file, using BCP. The sp creates temporary tables and the final select in sp is exec sp_executesql @.comm.
The following example demonstrates the problem:

declare @.bcpCommand nvarchar(100)
set @.bcpCommand = 'bcp "exec sp_helpdb" queryout "\\kkkk\bcp_dbs.log" -c'
exec master..xp_cmdshell @.bcpCommand

I'm getting the following error:
Password:
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]BCP host-files must contain at least one column
NULL

Thanksdeclare @.bcpCommand nvarchar(100)
set @.bcpCommand = 'bcp "set fmtonly off exec sp_helpdb" queryout "c:\test.txt" -c'
exec master..xp_cmdshell @.bcpCommand|||Damn...who was that (un)masked man??

Very nice...but it's as clear as mud

BOL

Returns only meta data to the client.

Syntax
SET FMTONLY { ON | OFF }

Remarks
No rows are processed or sent to the client as a result of the request when SET FMTONLY is turned ON.

The setting of SET FMTONLY is set at execute or run time and not at parse time.

Permissions
SET FMTONLY permissions default to all users.

Examples
This example changes the SET FMTONLY setting to ON and executes a SELECT statement. The setting causes the statement to return the column information only; no rows of data are returned.

SET FMTONLY ON
GO
USE pubs
GO
SELECT *
FROM pubs.dbo.authors
GO|||Thanks for the replay - it works .

2012年2月25日星期六

bcp connection problems

Well this one is puzzling me, and there is probably a very simple answer to this but coming from a linux/MySQL background to a windows/MSSQL system I can't figure it out.

Anyways I run bcp with my queryout string which is

bcp "SELECT * FROM edrdata.dbo.tblcomments WHERE siteid=-1" queryout "C:\DKD\" -c -U <username> -P <password> -S WELLDAQ\DBINFO

but I get an ODBC connection error, see below :

SQLState = 08001, NativeError = 17
Error = [Microsoft][ODBC SQL Server Driver][Shared Memory] SQL Server does not exist or access denied.
SQLState = 01000, NativeError = 2
Warning = [Microsoft][ODBC SQL Server Driver][Shared memory]ConnectionOpen (Connect()).

oh and SQL Server Service Manager shows the Server as WELLDAQ\DBINFO and it is running and I can connect to it through other means such as my visual basic applications I'm coding and through Visual Studio 2005 (remotely) so why can't bcp connect to it?

pls check your your surface area configuration if

1. the server is running in mixed mode

2. the server is configured to accept both local and remote connection

|||

Make sure there are no spaces between the -U and the username. Same for -P and -S

Also, specify a filename as well as the directory path and put the -S parameter before the -U and -P

Hope this helps.