[Microsoft][SQL Native Client]Unable to open BCP host data-file

by John 3. July 2009 07:10
Sometimes this ERROR is just file system permissions. It is definatelya generic error and not reporting what is actually going on.

Test by trying to write the the directory e.g. from SQL
EXEC xp_cmdshell '@ECHO hi! > E:\MSSQL\Tests\hi.txt'

If you get a security message, change the permissions of the directory e.g. Tests, above, to RW.
Categories: DOS | SQL

USAGE: SQLCMD DOS Commands from T-SQL Script

by John 20. September 2007 03:00

USAGE: SQLCMD DOS Commands from T-SQL Script

Log into the local sql server, trusted account and run a DOS command.

DECLARE @vcCmd varchar(8000)
SET @vcCmd = 'sqlcmd -S' + @@SERVERNAME + ' -E -Q":!! DIR C:\"'
EXEC xp_cmdshell @vcCmd
Tags:
Categories: DOS | SQLCMD