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

2012年3月27日星期二

bcp won't run

I'm having trouble running bcp from a command line. It fails without an error
message and closes the DOS window.
Does anyone know what I might be missing here?
-Nik JohnsonAre you running from a .BAT file, or typing in the BCP command in Windows, Start, Rum? If from a BAT file, out
PAUSE after the BCP command. If start, don't. Open a DOS windows so you get a proper command prompt and run
from there.
I don't think I've ever heard of a command line app closing a command window,,,
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Nik Johnson" <Nik Johnson@.discussions.microsoft.com> wrote in message
news:A6D6EB0B-BF4B-4DED-8BFE-E99D954F2D9A@.microsoft.com...
> I'm having trouble running bcp from a command line. It fails without an error
> message and closes the DOS window.
> Does anyone know what I might be missing here?
> -Nik Johnson|||I think the window closing happened because I tried running from a shortcut.
"Tibor Karaszi" wrote:
> Are you running from a .BAT file, or typing in the BCP command in Windows, Start, Rum? If from a BAT file, out
> PAUSE after the BCP command. If start, don't. Open a DOS windows so you get a proper command prompt and run
> from there.
> I don't think I've ever heard of a command line app closing a command window,,,
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Nik Johnson" <Nik Johnson@.discussions.microsoft.com> wrote in message
> news:A6D6EB0B-BF4B-4DED-8BFE-E99D954F2D9A@.microsoft.com...
> > I'm having trouble running bcp from a command line. It fails without an error
> > message and closes the DOS window.
> >
> > Does anyone know what I might be missing here?
> >
> > -Nik Johnson
>
>|||C>A little more experimentation shows that if I RUN the whole path
(command.com C:\Program Files\Microsoft SQL Server\80\Tools\Binn\bcp.exe) I
get the following:
Parameter format not correct
Specified COMMAND search directory bad
Too many parameters
Too many parameters
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-1999.
If I move everything to a directory immediately under the root (c:bcp) I get
a message: "Unable to load BCP resource DLL. BCP cannot continue."
-Nik
"Tibor Karaszi" wrote:
> Are you running from a .BAT file, or typing in the BCP command in Windows, Start, Rum? If from a BAT file, out
> PAUSE after the BCP command. If start, don't. Open a DOS windows so you get a proper command prompt and run
> from there.
> I don't think I've ever heard of a command line app closing a command window,,,
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Nik Johnson" <Nik Johnson@.discussions.microsoft.com> wrote in message
> news:A6D6EB0B-BF4B-4DED-8BFE-E99D954F2D9A@.microsoft.com...
> > I'm having trouble running bcp from a command line. It fails without an error
> > message and closes the DOS window.
> >
> > Does anyone know what I might be missing here?
> >
> > -Nik Johnson
>
>|||Nik,
Type command.com /? (at a command prompt) for a summary of how to use
command.com.
Type bcp (at a command prompt for a summary of how to use bcp.
Running bcp.exe with no parameters does not cause an error. It
displays the various switches that can be used with bcp and returns
control to the caller. That's what you're seeing when you run a batch
containing nothing but one line saying bcp or bcp.exe. What are you
expecting? As far as I know, there is no interactive mode for bcp, so
you can't just "start bcp" and then enter commands.
Steve Kass
Drew University
Nik Johnson wrote:
>C>A little more experimentation shows that if I RUN the whole path
>(command.com C:\Program Files\Microsoft SQL Server\80\Tools\Binn\bcp.exe) I
>get the following:
>Parameter format not correct
>Specified COMMAND search directory bad
>Too many parameters
>Too many parameters
>Microsoft(R) Windows DOS
>(C)Copyright Microsoft Corp 1990-1999.
>If I move everything to a directory immediately under the root (c:bcp) I get
>a message: "Unable to load BCP resource DLL. BCP cannot continue."
>-Nik
>
>
>"Tibor Karaszi" wrote:
>
>>Are you running from a .BAT file, or typing in the BCP command in Windows, Start, Rum? If from a BAT file, out
>>PAUSE after the BCP command. If start, don't. Open a DOS windows so you get a proper command prompt and run
>>from there.
>>I don't think I've ever heard of a command line app closing a command window,,,
>>--
>>Tibor Karaszi, SQL Server MVP
>>http://www.karaszi.com/sqlserver/default.asp
>>http://www.solidqualitylearning.com/
>>
>>"Nik Johnson" <Nik Johnson@.discussions.microsoft.com> wrote in message
>>news:A6D6EB0B-BF4B-4DED-8BFE-E99D954F2D9A@.microsoft.com...
>>
>>I'm having trouble running bcp from a command line. It fails without an error
>>message and closes the DOS window.
>>Does anyone know what I might be missing here?
>>-Nik Johnson
>>
>>|||Steve-
I'm expecting exactly the behavior that you describe, i.e., a summary of how
to use bcp. But instead I get a message that a dll can't be loaded.
I have a feeling that the necessary dll is either missing or not in the
path. But I have no idea what that dll is.
-Nik
"Steve Kass" wrote:
> Nik,
> Type command.com /? (at a command prompt) for a summary of how to use
> command.com.
> Type bcp (at a command prompt for a summary of how to use bcp.
> Running bcp.exe with no parameters does not cause an error. It
> displays the various switches that can be used with bcp and returns
> control to the caller. That's what you're seeing when you run a batch
> containing nothing but one line saying bcp or bcp.exe. What are you
> expecting? As far as I know, there is no interactive mode for bcp, so
> you can't just "start bcp" and then enter commands.
> Steve Kass
> Drew University
> Nik Johnson wrote:
> >C>A little more experimentation shows that if I RUN the whole path
> >(command.com C:\Program Files\Microsoft SQL Server\80\Tools\Binn\bcp.exe) I
> >get the following:
> >
> >Parameter format not correct
> >Specified COMMAND search directory bad
> >Too many parameters
> >Too many parameters
> >Microsoft(R) Windows DOS
> >(C)Copyright Microsoft Corp 1990-1999.
> >
> >If I move everything to a directory immediately under the root (c:bcp) I get
> >a message: "Unable to load BCP resource DLL. BCP cannot continue."
> >
> >-Nik
> >
> >
> >
> >
> >"Tibor Karaszi" wrote:
> >
> >
> >
> >>Are you running from a .BAT file, or typing in the BCP command in Windows, Start, Rum? If from a BAT file, out
> >>PAUSE after the BCP command. If start, don't. Open a DOS windows so you get a proper command prompt and run
> >>from there.
> >>
> >>I don't think I've ever heard of a command line app closing a command window,,,
> >>
> >>--
> >>Tibor Karaszi, SQL Server MVP
> >>http://www.karaszi.com/sqlserver/default.asp
> >>http://www.solidqualitylearning.com/
> >>
> >>
> >>"Nik Johnson" <Nik Johnson@.discussions.microsoft.com> wrote in message
> >>news:A6D6EB0B-BF4B-4DED-8BFE-E99D954F2D9A@.microsoft.com...
> >>
> >>
> >>I'm having trouble running bcp from a command line. It fails without an error
> >>message and closes the DOS window.
> >>
> >>Does anyone know what I might be missing here?
> >>
> >>-Nik Johnson
> >>
> >>
> >>
> >>
> >>
>

2012年3月22日星期四

BCP Problems

Hello, I am wanting to take the output of sp_who2 to and
output file and then send that file in an email message
all within a PROC. I was thinking that I should
use "xp_cmdShell" and execute the BCP command. After
trying a number of times to get it to work, someone
provided me the following and indicated that it work find
on their machine. So all I did was change the server
address and run, but it still generates an error. Here
is the command:
master..xp_cmdshell 'bcp "exec master..sp_who" queryout
"C:\SQLTestOutput.txt" -c -T -S "Fred\NetSDK" '
Here is the error that I get.
usage: bcp {dbtable | query} {in | out | queryout |
format} datafile
[-m maxerrors] [-f formatfile] [-e
errfile]
[-F firstrow] [-L lastrow] [-b
batchsize]
[-n native type] [-c character type] [-w
wide character type]
[-N keep non-text native] [-V file format version] [-q
quoted identifier]
[-C code page specifier] [-t field terminator] [-r
row terminator]
[-i inputfile] [-o outfile] [-a
packetsize]
[-S server name] [-U username] [-P
password]
[-T trusted connection] [-v version] [-R
regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
NULL
(12 row(s) affected)
There is no output file created - so I can not tell if it
is telling me that I have a format error, or if this is
the type of message I would get if it works. If it
worked, where is the file?I figured it out - it did not like the command spread
over two lines.
>--Original Message--
>Hello, I am wanting to take the output of sp_who2 to and
>output file and then send that file in an email message
>all within a PROC. I was thinking that I should
>use "xp_cmdShell" and execute the BCP command. After
>trying a number of times to get it to work, someone
>provided me the following and indicated that it work
find
>on their machine. So all I did was change the server
>address and run, but it still generates an error. Here
>is the command:
>master..xp_cmdshell 'bcp "exec master..sp_who" queryout
>"C:\SQLTestOutput.txt" -c -T -S "Fred\NetSDK" '
>Here is the error that I get.
>usage: bcp {dbtable | query} {in | out | queryout |
>format} datafile
> [-m maxerrors] [-f formatfile] [-e
>errfile]
> [-F firstrow] [-L lastrow] [-b
>batchsize]
> [-n native type] [-c character type] [-w
>wide character type]
> [-N keep non-text native] [-V file format version] [-q
>quoted identifier]
> [-C code page specifier] [-t field terminator] [-r
>row terminator]
> [-i inputfile] [-o outfile] [-a
>packetsize]
> [-S server name] [-U username] [-P
>password]
> [-T trusted connection] [-v version] [-R
>regional enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
>NULL
>(12 row(s) affected)
>There is no output file created - so I can not tell if
it
>is telling me that I have a format error, or if this is
>the type of message I would get if it works. If it
>worked, where is the file?
>.
>sql

2012年3月19日星期一

BCP in xp_cmdshell

Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
exec xp_cmdshell 'bcp '
It gives me generic usage message like
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-6 6x file format] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
EXCEPT in one server where I get the error below when executed through
xp_cmdshell (works fine in Command Prompt)
'bcp' is not recognized as an internal or external command,
operable program or batch file.
NULL
I am not using any account to run the SQL Server services.
Anyone, any idea?
--
Regards,
MZeeshanYou're going to need to give SQL Server more info to go on.
> exec xp_cmdshell 'bcp '
You need to specify "in","out",where the file is, etc. That's what the
generic message is telling you.
"MZeeshan" <mzeeshan@.community.nospam> wrote in message
news:3980BBF1-688F-48EB-9BE3-7EBF6DFB0B4C@.microsoft.com...
> Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> exec xp_cmdshell 'bcp '
> It gives me generic usage message like
> usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> [-m maxerrors] [-f formatfile] [-e errfile]
> [-F firstrow] [-L lastrow] [-b batchsize]
> [-n native type] [-c character type] [-w wide character type]
> [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> [-C code page specifier] [-t field terminator] [-r row terminator]
> [-i inputfile] [-o outfile] [-a packetsize]
> [-S server name] [-U username] [-P password]
> [-T trusted connection] [-v version] [-R regional enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
> EXCEPT in one server where I get the error below when executed through
> xp_cmdshell (works fine in Command Prompt)
> 'bcp' is not recognized as an internal or external command,
> operable program or batch file.
> NULL
> I am not using any account to run the SQL Server services.
> Anyone, any idea?
> --
> Regards,
> MZeeshan|||I was just trying to give the simplest of the bcp options. Here, I was just
trying to explain there is some PATH issue in the shell when bcp is executed
from xp_cmdshell.
Regards,
MZeeshan
"ChrisR" wrote:
> You're going to need to give SQL Server more info to go on.
> > exec xp_cmdshell 'bcp '
> You need to specify "in","out",where the file is, etc. That's what the
> generic message is telling you.
>
> "MZeeshan" <mzeeshan@.community.nospam> wrote in message
> news:3980BBF1-688F-48EB-9BE3-7EBF6DFB0B4C@.microsoft.com...
> > Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> >
> > exec xp_cmdshell 'bcp '
> >
> > It gives me generic usage message like
> >
> > usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> > [-m maxerrors] [-f formatfile] [-e errfile]
> > [-F firstrow] [-L lastrow] [-b batchsize]
> > [-n native type] [-c character type] [-w wide character type]
> > [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> > [-C code page specifier] [-t field terminator] [-r row terminator]
> > [-i inputfile] [-o outfile] [-a packetsize]
> > [-S server name] [-U username] [-P password]
> > [-T trusted connection] [-v version] [-R regional enable]
> > [-k keep null values] [-E keep identity values]
> > [-h "load hints"]
> >
> > EXCEPT in one server where I get the error below when executed through
> > xp_cmdshell (works fine in Command Prompt)
> >
> > 'bcp' is not recognized as an internal or external command,
> > operable program or batch file.
> > NULL
> >
> > I am not using any account to run the SQL Server services.
> >
> > Anyone, any idea?
> >
> > --
> > Regards,
> > MZeeshan
>
>|||May be the binn (example: C:\Program Files\Microsoft SQL
Server\80\Tools\BINN) directory is not in the os variable "path" and
xp_cmdshell is trying to execute the cmd from another dir.
AMB
"MZeeshan" wrote:
> Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> exec xp_cmdshell 'bcp '
> It gives me generic usage message like
> usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> [-m maxerrors] [-f formatfile] [-e errfile]
> [-F firstrow] [-L lastrow] [-b batchsize]
> [-n native type] [-c character type] [-w wide character type]
> [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> [-C code page specifier] [-t field terminator] [-r row terminator]
> [-i inputfile] [-o outfile] [-a packetsize]
> [-S server name] [-U username] [-P password]
> [-T trusted connection] [-v version] [-R regional enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
> EXCEPT in one server where I get the error below when executed through
> xp_cmdshell (works fine in Command Prompt)
> 'bcp' is not recognized as an internal or external command,
> operable program or batch file.
> NULL
> I am not using any account to run the SQL Server services.
> Anyone, any idea?
> --
> Regards,
> MZeeshan|||I have checked the path is present in the PATH variable in System Variables.
Plus, I can run bcp in Command Prompt
--
Regards,
MZeeshan
"Alejandro Mesa" wrote:
> May be the binn (example: C:\Program Files\Microsoft SQL
> Server\80\Tools\BINN) directory is not in the os variable "path" and
> xp_cmdshell is trying to execute the cmd from another dir.
>
> AMB
> "MZeeshan" wrote:
> > Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> >
> > exec xp_cmdshell 'bcp '
> >
> > It gives me generic usage message like
> >
> > usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> > [-m maxerrors] [-f formatfile] [-e errfile]
> > [-F firstrow] [-L lastrow] [-b batchsize]
> > [-n native type] [-c character type] [-w wide character type]
> > [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> > [-C code page specifier] [-t field terminator] [-r row terminator]
> > [-i inputfile] [-o outfile] [-a packetsize]
> > [-S server name] [-U username] [-P password]
> > [-T trusted connection] [-v version] [-R regional enable]
> > [-k keep null values] [-E keep identity values]
> > [-h "load hints"]
> >
> > EXCEPT in one server where I get the error below when executed through
> > xp_cmdshell (works fine in Command Prompt)
> >
> > 'bcp' is not recognized as an internal or external command,
> > operable program or batch file.
> > NULL
> >
> > I am not using any account to run the SQL Server services.
> >
> > Anyone, any idea?
> >
> > --
> > Regards,
> > MZeeshan|||Can you run this statement from QA?
exec master..xp_cmdshell 'path && cd'
> I have checked the path is present in the PATH variable in System Variables.
> Plus, I can run bcp in Command Prompt
How are accesing the command prompt?
AMB
"MZeeshan" wrote:
> I have checked the path is present in the PATH variable in System Variables.
> Plus, I can run bcp in Command Prompt
> --
> Regards,
> MZeeshan
>
> "Alejandro Mesa" wrote:
> > May be the binn (example: C:\Program Files\Microsoft SQL
> > Server\80\Tools\BINN) directory is not in the os variable "path" and
> > xp_cmdshell is trying to execute the cmd from another dir.
> >
> >
> > AMB
> >
> > "MZeeshan" wrote:
> >
> > > Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> > >
> > > exec xp_cmdshell 'bcp '
> > >
> > > It gives me generic usage message like
> > >
> > > usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> > > [-m maxerrors] [-f formatfile] [-e errfile]
> > > [-F firstrow] [-L lastrow] [-b batchsize]
> > > [-n native type] [-c character type] [-w wide character type]
> > > [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> > > [-C code page specifier] [-t field terminator] [-r row terminator]
> > > [-i inputfile] [-o outfile] [-a packetsize]
> > > [-S server name] [-U username] [-P password]
> > > [-T trusted connection] [-v version] [-R regional enable]
> > > [-k keep null values] [-E keep identity values]
> > > [-h "load hints"]
> > >
> > > EXCEPT in one server where I get the error below when executed through
> > > xp_cmdshell (works fine in Command Prompt)
> > >
> > > 'bcp' is not recognized as an internal or external command,
> > > operable program or batch file.
> > > NULL
> > >
> > > I am not using any account to run the SQL Server services.
> > >
> > > Anyone, any idea?
> > >
> > > --
> > > Regards,
> > > MZeeshan|||Thanks... this indeed worked.
What I found out that due to re-installation of SQL Server, the path
'c:\program files..\binn' has been pushed to the end and it was not appearing
in the xp_cmdshell 'path'.
Once the change was made, I had to reboot the server (just merely
stopping/restarting SQL server didn't help).
It's fine now!!!
--
Regards,
MZeeshan
"Alejandro Mesa" wrote:
> Can you run this statement from QA?
> exec master..xp_cmdshell 'path && cd'
> > I have checked the path is present in the PATH variable in System Variables.
> > Plus, I can run bcp in Command Prompt
> How are accesing the command prompt?
>
> AMB
> "MZeeshan" wrote:
> > I have checked the path is present in the PATH variable in System Variables.
> > Plus, I can run bcp in Command Prompt
> >
> > --
> > Regards,
> > MZeeshan
> >
> >
> > "Alejandro Mesa" wrote:
> >
> > > May be the binn (example: C:\Program Files\Microsoft SQL
> > > Server\80\Tools\BINN) directory is not in the os variable "path" and
> > > xp_cmdshell is trying to execute the cmd from another dir.
> > >
> > >
> > > AMB
> > >
> > > "MZeeshan" wrote:
> > >
> > > > Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> > > >
> > > > exec xp_cmdshell 'bcp '
> > > >
> > > > It gives me generic usage message like
> > > >
> > > > usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> > > > [-m maxerrors] [-f formatfile] [-e errfile]
> > > > [-F firstrow] [-L lastrow] [-b batchsize]
> > > > [-n native type] [-c character type] [-w wide character type]
> > > > [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> > > > [-C code page specifier] [-t field terminator] [-r row terminator]
> > > > [-i inputfile] [-o outfile] [-a packetsize]
> > > > [-S server name] [-U username] [-P password]
> > > > [-T trusted connection] [-v version] [-R regional enable]
> > > > [-k keep null values] [-E keep identity values]
> > > > [-h "load hints"]
> > > >
> > > > EXCEPT in one server where I get the error below when executed through
> > > > xp_cmdshell (works fine in Command Prompt)
> > > >
> > > > 'bcp' is not recognized as an internal or external command,
> > > > operable program or batch file.
> > > > NULL
> > > >
> > > > I am not using any account to run the SQL Server services.
> > > >
> > > > Anyone, any idea?
> > > >
> > > > --
> > > > Regards,
> > > > MZeeshan

BCP in xp_cmdshell

Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
exec xp_cmdshell 'bcp '
It gives me generic usage message like
usage: bcp {dbtable | query} {in | out | queryout | format} datafi
le
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide charact
er type]
[-N keep non-text native] [-6 6x file format] [-q quoted ident
ifier]
[-C code page specifier] [-t field terminator] [-r row terminat
or]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional ena
ble]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
EXCEPT in one server where I get the error below when executed through
xp_cmdshell (works fine in Command Prompt)
'bcp' is not recognized as an internal or external command,
operable program or batch file.
NULL
I am not using any account to run the SQL Server services.
Anyone, any idea?
Regards,
MZeeshanYou're going to need to give SQL Server more info to go on.
> exec xp_cmdshell 'bcp '
You need to specify "in","out",where the file is, etc. That's what the
generic message is telling you.
"MZeeshan" <mzeeshan@.community.nospam> wrote in message
news:3980BBF1-688F-48EB-9BE3-7EBF6DFB0B4C@.microsoft.com...
> Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> exec xp_cmdshell 'bcp '
> It gives me generic usage message like
> usage: bcp {dbtable | query} {in | out | queryout | format} data
file
> [-m maxerrors] [-f formatfile] [-e errfile]
> [-F firstrow] [-L lastrow] [-b batchsize
]
> [-n native type] [-c character type] [-w wide char
acter type]
> [-N keep non-text native] [-6 6x file format] [-q quoted id
entifier]
> [-C code page specifier] [-t field terminator] [-r row termi
nator]
> [-i inputfile] [-o outfile] [-a packetsiz
e]
> [-S server name] [-U username] [-P password]
> [-T trusted connection] [-v version] [-R regional
enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
> EXCEPT in one server where I get the error below when executed through
> xp_cmdshell (works fine in Command Prompt)
> 'bcp' is not recognized as an internal or external command,
> operable program or batch file.
> NULL
> I am not using any account to run the SQL Server services.
> Anyone, any idea?
> --
> Regards,
> MZeeshan|||I was just trying to give the simplest of the bcp options. Here, I was just
trying to explain there is some PATH issue in the shell when bcp is executed
from xp_cmdshell.
Regards,
MZeeshan
"ChrisR" wrote:

> You're going to need to give SQL Server more info to go on.
> You need to specify "in","out",where the file is, etc. That's what the
> generic message is telling you.
>
> "MZeeshan" <mzeeshan@.community.nospam> wrote in message
> news:3980BBF1-688F-48EB-9BE3-7EBF6DFB0B4C@.microsoft.com...
>
>|||May be the binn (example: C:\Program Files\Microsoft SQL
Server\80\Tools\BINN) directory is not in the os variable "path" and
xp_cmdshell is trying to execute the cmd from another dir.
AMB
"MZeeshan" wrote:

> Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> exec xp_cmdshell 'bcp '
> It gives me generic usage message like
> usage: bcp {dbtable | query} {in | out | queryout | format} data
file
> [-m maxerrors] [-f formatfile] [-e errfile]
> [-F firstrow] [-L lastrow] [-b batchsiz
e]
> [-n native type] [-c character type] [-w wide cha
racter type]
> [-N keep non-text native] [-6 6x file format] [-q quoted i
dentifier]
> [-C code page specifier] [-t field terminator] [-r row term
inator]
> [-i inputfile] [-o outfile] [-a packetsi
ze]
> [-S server name] [-U username] [-P password
]
> [-T trusted connection] [-v version] [-R regional
enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
> EXCEPT in one server where I get the error below when executed through
> xp_cmdshell (works fine in Command Prompt)
> 'bcp' is not recognized as an internal or external command,
> operable program or batch file.
> NULL
> I am not using any account to run the SQL Server services.
> Anyone, any idea?
> --
> Regards,
> MZeeshan|||I have checked the path is present in the PATH variable in System Variables.
Plus, I can run bcp in Command Prompt
Regards,
MZeeshan
"Alejandro Mesa" wrote:
[vbcol=seagreen]
> May be the binn (example: C:\Program Files\Microsoft SQL
> Server\80\Tools\BINN) directory is not in the os variable "path" and
> xp_cmdshell is trying to execute the cmd from another dir.
>
> AMB
> "MZeeshan" wrote:
>|||Can you run this statement from QA?
exec master..xp_cmdshell 'path && cd'

> I have checked the path is present in the PATH variable in System Variable
s.
> Plus, I can run bcp in Command Prompt
How are accesing the command prompt?
AMB
"MZeeshan" wrote:
[vbcol=seagreen]
> I have checked the path is present in the PATH variable in System Variable
s.
> Plus, I can run bcp in Command Prompt
> --
> Regards,
> MZeeshan
>
> "Alejandro Mesa" wrote:
>|||Thanks... this indeed worked.
What I found out that due to re-installation of SQL Server, the path
'c:\program files..\binn' has been pushed to the end and it was not appearin
g
in the xp_cmdshell 'path'.
Once the change was made, I had to reboot the server (just merely
stopping/restarting SQL server didn't help).
It's fine now!!!
Regards,
MZeeshan
"Alejandro Mesa" wrote:
[vbcol=seagreen]
> Can you run this statement from QA?
> exec master..xp_cmdshell 'path && cd'
>
> How are accesing the command prompt?
>
> AMB
> "MZeeshan" wrote:
>

BCP in xp_cmdshell

Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
exec xp_cmdshell 'bcp '
It gives me generic usage message like
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-6 6x file format] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
EXCEPT in one server where I get the error below when executed through
xp_cmdshell (works fine in Command Prompt)
'bcp' is not recognized as an internal or external command,
operable program or batch file.
NULL
I am not using any account to run the SQL Server services.
Anyone, any idea?
Regards,
MZeeshan
You're going to need to give SQL Server more info to go on.
> exec xp_cmdshell 'bcp '
You need to specify "in","out",where the file is, etc. That's what the
generic message is telling you.
"MZeeshan" <mzeeshan@.community.nospam> wrote in message
news:3980BBF1-688F-48EB-9BE3-7EBF6DFB0B4C@.microsoft.com...
> Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> exec xp_cmdshell 'bcp '
> It gives me generic usage message like
> usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> [-m maxerrors] [-f formatfile] [-e errfile]
> [-F firstrow] [-L lastrow] [-b batchsize]
> [-n native type] [-c character type] [-w wide character type]
> [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> [-C code page specifier] [-t field terminator] [-r row terminator]
> [-i inputfile] [-o outfile] [-a packetsize]
> [-S server name] [-U username] [-P password]
> [-T trusted connection] [-v version] [-R regional enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
> EXCEPT in one server where I get the error below when executed through
> xp_cmdshell (works fine in Command Prompt)
> 'bcp' is not recognized as an internal or external command,
> operable program or batch file.
> NULL
> I am not using any account to run the SQL Server services.
> Anyone, any idea?
> --
> Regards,
> MZeeshan
|||I was just trying to give the simplest of the bcp options. Here, I was just
trying to explain there is some PATH issue in the shell when bcp is executed
from xp_cmdshell.
Regards,
MZeeshan
"ChrisR" wrote:

> You're going to need to give SQL Server more info to go on.
> You need to specify "in","out",where the file is, etc. That's what the
> generic message is telling you.
>
> "MZeeshan" <mzeeshan@.community.nospam> wrote in message
> news:3980BBF1-688F-48EB-9BE3-7EBF6DFB0B4C@.microsoft.com...
>
>
|||May be the binn (example: C:\Program Files\Microsoft SQL
Server\80\Tools\BINN) directory is not in the os variable "path" and
xp_cmdshell is trying to execute the cmd from another dir.
AMB
"MZeeshan" wrote:

> Whenever I execute 'bcp' in Command Prompt or in xp_cmdshell such as
> exec xp_cmdshell 'bcp '
> It gives me generic usage message like
> usage: bcp {dbtable | query} {in | out | queryout | format} datafile
> [-m maxerrors] [-f formatfile] [-e errfile]
> [-F firstrow] [-L lastrow] [-b batchsize]
> [-n native type] [-c character type] [-w wide character type]
> [-N keep non-text native] [-6 6x file format] [-q quoted identifier]
> [-C code page specifier] [-t field terminator] [-r row terminator]
> [-i inputfile] [-o outfile] [-a packetsize]
> [-S server name] [-U username] [-P password]
> [-T trusted connection] [-v version] [-R regional enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
> EXCEPT in one server where I get the error below when executed through
> xp_cmdshell (works fine in Command Prompt)
> 'bcp' is not recognized as an internal or external command,
> operable program or batch file.
> NULL
> I am not using any account to run the SQL Server services.
> Anyone, any idea?
> --
> Regards,
> MZeeshan
|||I have checked the path is present in the PATH variable in System Variables.
Plus, I can run bcp in Command Prompt
Regards,
MZeeshan
"Alejandro Mesa" wrote:
[vbcol=seagreen]
> May be the binn (example: C:\Program Files\Microsoft SQL
> Server\80\Tools\BINN) directory is not in the os variable "path" and
> xp_cmdshell is trying to execute the cmd from another dir.
>
> AMB
> "MZeeshan" wrote:
|||Can you run this statement from QA?
exec master..xp_cmdshell 'path && cd'

> I have checked the path is present in the PATH variable in System Variables.
> Plus, I can run bcp in Command Prompt
How are accesing the command prompt?
AMB
"MZeeshan" wrote:
[vbcol=seagreen]
> I have checked the path is present in the PATH variable in System Variables.
> Plus, I can run bcp in Command Prompt
> --
> Regards,
> MZeeshan
>
> "Alejandro Mesa" wrote:
|||Thanks... this indeed worked.
What I found out that due to re-installation of SQL Server, the path
'c:\program files..\binn' has been pushed to the end and it was not appearing
in the xp_cmdshell 'path'.
Once the change was made, I had to reboot the server (just merely
stopping/restarting SQL server didn't help).
It's fine now!!!
Regards,
MZeeshan
"Alejandro Mesa" wrote:
[vbcol=seagreen]
> Can you run this statement from QA?
> exec master..xp_cmdshell 'path && cd'
>
> How are accesing the command prompt?
>
> AMB
> "MZeeshan" wrote:

2012年3月11日星期日

bcp help

Hi!
Trying to run this command:
bcp Risk.dbo.tbl_Open in C:\temp2\2006.05.11-09.20.11.11\Risk\Open.txt
-T -n
getting the followin error message:
SQLState = 37000, Native Error = 156
Incorrect Syntax near the keyword 'Open'.
I can't not rename a table. Is there a work around?
Thanks,Are you executing this in Query Analyzer or from an operating system command prompt. BCP is not a
TSQL command. If you want to run a TSQL command, use BULK INSERT instead.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"tolcis" <a.liberchuk@.verizon.net> wrote in message
news:1147370866.716078.250460@.i40g2000cwc.googlegroups.com...
> Hi!
> Trying to run this command:
> bcp Risk.dbo.tbl_Open in C:\temp2\2006.05.11-09.20.11.11\Risk\Open.txt
> -T -n
> getting the followin error message:
> SQLState = 37000, Native Error = 156
> Incorrect Syntax near the keyword 'Open'.
> I can't not rename a table. Is there a work around?
> Thanks,
>|||I am executing from DOS command.|||That is strange since the error complain on the keyword Open where your code refers to a table named
tbl_Open. Anyhow, check out the -q option of bcp.exe.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
news:OmydNdSdGHA.3484@.TK2MSFTNGP04.phx.gbl...
> Are you executing this in Query Analyzer or from an operating system command prompt. BCP is not a
> TSQL command. If you want to run a TSQL command, use BULK INSERT instead.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "tolcis" <a.liberchuk@.verizon.net> wrote in message
> news:1147370866.716078.250460@.i40g2000cwc.googlegroups.com...
>> Hi!
>> Trying to run this command:
>> bcp Risk.dbo.tbl_Open in C:\temp2\2006.05.11-09.20.11.11\Risk\Open.txt
>> -T -n
>> getting the followin error message:
>> SQLState = 37000, Native Error = 156
>> Incorrect Syntax near the keyword 'Open'.
>> I can't not rename a table. Is there a work around?
>> Thanks,
>

2012年3月8日星期四

BCP fails with 134 columns

I'm trying to BCP from a csv file to a table, both have 134 columns. The error message coming back from BCP "SQLState = 37000, NativeError = 170

Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '1'."

By reducing the number of columns in both csv file and table to around 20 column , the bcp call will work and the data will load into the table.Here's a sample that shows the problem

The command line I'm using to call bcp:-

"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\bcp.exe" em.dbo.mytable1 in c:\temp\_rrs\datafile.csv -S SQL_SERVER_NAME -U username -P password -t "|" -c -F 2

The version of BCP this is using :- 8.00.194 on SQL Server 2000.

Sample data in datafile.csv

1|Position|BBPLC|20060927|ALL|RDPBB092701.DAT||ALL
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1
2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2|2
3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3|3

Creation script for table


if exists (select * from dbo.sysobjects where id = object_id(N'[mytable1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [mytable1]
GO

CREATE TABLE [mytable1] (
[1][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[2][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[3][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[4][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[5][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
Devil[varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[7][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
Music[varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[9][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[10][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[11][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[12][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[13][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[14][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[15][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[16][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[17][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[18][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[19][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[20][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[21][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[22][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[23][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[24][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[25][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[26][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[27][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[28][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[29][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[30][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[31][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[32][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[33][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[34][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[35][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[36][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[37][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[38][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[39][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[40][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[41][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[42][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[43][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[44][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[45][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[46][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[47][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[48][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[49][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[50][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[51][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[52][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[53][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[54][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[55][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[56][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[57][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[58][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[59][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[60][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[61][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[62][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[63][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[64][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[65][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[66][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[67][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[68][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[69][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[70][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[71][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[72][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[73][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[74][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[75][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[76][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[77][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[78][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[79][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[80][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[81][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[82][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[83][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[84][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[85][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[86][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[87][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[88][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[89][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[90][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[91][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[92][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[93][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[94][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[95][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[96][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[97][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[98][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[99][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[100][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[101][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[102][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[103][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[104][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[105][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[106][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[107][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[108][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[109][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[110][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[111][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[112][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[113][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[114][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[115][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[116][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[117][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[118][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[119][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[120][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[121][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[122][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[123][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[124][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[125][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[126][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[127][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[128][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[129][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[130][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[131][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[132][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[133][varchar](6) COLLATE Latin1_General_CI_AS NULL ,
[134][varchar](6) COLLATE Latin1_General_CI_AS NULL
) ON [em_Group1]
GO

Any pointers on this would be very much appreciated

Regards

RichardS71


Eureka!

Whilst SQL Server allows you to create tables with column names that begin with a number, BCP version 8.00.XXX won't let you BCP to the table.

2012年3月6日星期二

bcp error: Truncation cannot occur for BCP output file

Hi,

I'm trying to export sql table as fixed length text file with format file but I got the following error message:


Error = [Microsoft][ODBC SQL Server Driver][SQL Server]
Warning: Server data (61 bytes) exceeds host-file field length (60 bytes) for field (4).
Use prefix length, termination string, or a larger host-file field size.
Truncation cannot occur for BCP output file


All fields in the SQL input table have char data type and I use the format file like this:


7.0
29
1 SQLCHAR 0 10 "" 1 SEQ
2 SQLCHAR 0 1 "" 2 NPARSED
3 SQLCHAR 0 115 "" 3 COMPANY
4 SQLCHAR 0 60 "" 4 ADDR1
....
27 SQLCHAR 0 1 "" 27 LACS
28 SQLCHAR 0 2 "" 28 DPV
29 SQLCHAR 0 2 "\r\n" 29 ZIP4CODE


I've been researched about this error but I couldn't find the clear answer.

The strange thing is that all the records are char() fields, not varchar()

And I checked the max length record for the 4th column(ADDR1) and it was 60, not 61.

However I'm still getting the error.

The output file was exported but some of the records have short length.

Is this some kind of bcp bug?

I used SQL Server 2000 Standard w/ SP4

And the following is the command that I used:


declare @.cmd varchar(2000)

SET @.cmd = 'bcp "Input_table" out "D:\AddressUpdate\Tmp\xFixADDR.dat" -fD:\AddressUpdate\Tmp\xFixADDR.fmt -Usa -Psapass -SMyMachine''
print(@.cmd)
EXEC master..xp_cmdshell @.cmd


Please let me know if anyone solve the similar problem.

Thanks,

- Hyung -

Hyung,

Are the client and server code pages different. Translation of data from one code page to another results in larger size for the destination data than the original size. This is specially common in east-asian languages like Chinese, Japanese etc.

Also, what server/client versions are you using? The error seems to come from bcp executable which comes with SQL Server 2000, if you have SQL Server 2005 make sure you use the SQL Server 2005 version of bcp executable. You can check that by using bcp /v command, where version should be 09.XX.XXXX

Thanks

Waseem

|||

Thank you for your answer.

I changed the server collation by rebuilding the master database upon your advice and it solved the problem.

The SQL server version that I'm using is a kind of mixed.

I'd installed SQL Server 2000 personal edition (default) on my machine and I also installed SQL Server 2005 Developer edition on the same machine as Named instance.

It made me prevent using SQL 2000 version of Enterprise Manager with error something like "MMC was created by a later version"

And the program was created from SQL project in the Visual Studio 2005 standard edition and one IS package file is used inside the program.

Also one of the "Execute SQL Task" in the pacakge uses bcp command on the SQL Server 2000 machines.

Thank you again,

- Hyung -

bcp error: Truncation cannot occur for BCP output file

Hi,

I'm trying to export sql table as fixed length text file with format file but I got the following error message:


Error = [Microsoft][ODBC SQL Server Driver][SQL Server]
Warning: Server data (61 bytes) exceeds host-file field length (60 bytes) for field (4).
Use prefix length, termination string, or a larger host-file field size.
Truncation cannot occur for BCP output file


All fields in the SQL input table have char data type and I use the format file like this:


7.0
29
1 SQLCHAR 0 10 "" 1 SEQ
2 SQLCHAR 0 1 "" 2 NPARSED
3 SQLCHAR 0 115 "" 3 COMPANY
4 SQLCHAR 0 60 "" 4 ADDR1
....
27 SQLCHAR 0 1 "" 27 LACS
28 SQLCHAR 0 2 "" 28 DPV
29 SQLCHAR 0 2 "\r\n" 29 ZIP4CODE


I've been researched about this error but I couldn't find the clear answer.

The strange thing is that all the records are char() fields, not varchar()

And I checked the max length record for the 4th column(ADDR1) and it was 60, not 61.

However I'm still getting the error.

The output file was exported but some of the records have short length.

Is this some kind of bcp bug?

I used SQL Server 2000 Standard w/ SP4

And the following is the command that I used:


declare @.cmd varchar(2000)

SET @.cmd = 'bcp "Input_table" out "D:\AddressUpdate\Tmp\xFixADDR.dat" -fD:\AddressUpdate\Tmp\xFixADDR.fmt -Usa -Psapass -SMyMachine''
print(@.cmd)
EXEC master..xp_cmdshell @.cmd


Please let me know if anyone solve the similar problem.

Thanks,

- Hyung -

Hyung,

Are the client and server code pages different. Translation of data from one code page to another results in larger size for the destination data than the original size. This is specially common in east-asian languages like Chinese, Japanese etc.

Also, what server/client versions are you using? The error seems to come from bcp executable which comes with SQL Server 2000, if you have SQL Server 2005 make sure you use the SQL Server 2005 version of bcp executable. You can check that by using bcp /v command, where version should be 09.XX.XXXX

Thanks

Waseem

|||

Thank you for your answer.

I changed the server collation by rebuilding the master database upon your advice and it solved the problem.

The SQL server version that I'm using is a kind of mixed.

I'd installed SQL Server 2000 personal edition (default) on my machine and I also installed SQL Server 2005 Developer edition on the same machine as Named instance.

It made me prevent using SQL 2000 version of Enterprise Manager with error something like "MMC was created by a later version"

And the program was created from SQL project in the Visual Studio 2005 standard edition and one IS package file is used inside the program.

Also one of the "Execute SQL Task" in the pacakge uses bcp command on the SQL Server 2000 machines.

Thank you again,

- Hyung -

BCP error message.

First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
this newsgroup so forgive me if I should have posted this question else where.
I'm trying to use bcp to output data from a table to a file but keep getting
the error, "An error occurred while trying to process the command line."
This is what I'm trying to execute throught he Command Prompt,
bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
Downloads\output.txt" -T -c -Sqisdevsql1
I'm running this from our development server, which is not where SQL Server
lives, we have a dedicated SQL Server box, qisdevsql1.
What am I doing wrong?This works on my machine. Can you run bcp -v from a command window and see
what you get?
--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"DaRock" <DaRock@.discussions.microsoft.com> wrote in message
news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
> First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
> this newsgroup so forgive me if I should have posted this question else
> where.
> I'm trying to use bcp to output data from a table to a file but keep
> getting
> the error, "An error occurred while trying to process the command line."
> This is what I'm trying to execute throught he Command Prompt,
> bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
> I'm running this from our development server, which is not where SQL
> Server
> lives, we have a dedicated SQL Server box, qisdevsql1.
> What am I doing wrong?
>|||I get, BCP - Bulk Copy Program, some registration info and then Version
9.00.1399.06.
Troy
"Hilary Cotter" wrote:
> This works on my machine. Can you run bcp -v from a command window and see
> what you get?
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "DaRock" <DaRock@.discussions.microsoft.com> wrote in message
> news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
> > First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
> > this newsgroup so forgive me if I should have posted this question else
> > where.
> >
> > I'm trying to use bcp to output data from a table to a file but keep
> > getting
> > the error, "An error occurred while trying to process the command line."
> >
> > This is what I'm trying to execute throught he Command Prompt,
> > bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> > Downloads\output.txt" -T -c -Sqisdevsql1
> >
> > I'm running this from our development server, which is not where SQL
> > Server
> > lives, we have a dedicated SQL Server box, qisdevsql1.
> >
> > What am I doing wrong?
> >
> >
>
>|||> bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
Since your database name does't confirm to the rules for identifiers, you
need to enclose the name in square brackets:
bcp [450_gilroy].dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
Downloads\output.txt" -T -c -Sqisdevsql1
Hope this helps.
Dan Guzman
SQL Server MVP
"DaRock" <DaRock@.discussions.microsoft.com> wrote in message
news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
> First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
> this newsgroup so forgive me if I should have posted this question else
> where.
> I'm trying to use bcp to output data from a table to a file but keep
> getting
> the error, "An error occurred while trying to process the command line."
> This is what I'm trying to execute throught he Command Prompt,
> bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
> I'm running this from our development server, which is not where SQL
> Server
> lives, we have a dedicated SQL Server box, qisdevsql1.
> What am I doing wrong?
>|||Yes that was it. Thanks!
"Dan Guzman" wrote:
> > bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> > Downloads\output.txt" -T -c -Sqisdevsql1
> Since your database name does't confirm to the rules for identifiers, you
> need to enclose the name in square brackets:
> bcp [450_gilroy].dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "DaRock" <DaRock@.discussions.microsoft.com> wrote in message
> news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
> > First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
> > this newsgroup so forgive me if I should have posted this question else
> > where.
> >
> > I'm trying to use bcp to output data from a table to a file but keep
> > getting
> > the error, "An error occurred while trying to process the command line."
> >
> > This is what I'm trying to execute throught he Command Prompt,
> > bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> > Downloads\output.txt" -T -c -Sqisdevsql1
> >
> > I'm running this from our development server, which is not where SQL
> > Server
> > lives, we have a dedicated SQL Server box, qisdevsql1.
> >
> > What am I doing wrong?
> >
> >
>
>

BCP error message.

First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
this newsgroup so forgive me if I should have posted this question else wher
e.
I'm trying to use bcp to output data from a table to a file but keep getting
the error, "An error occurred while trying to process the command line."
This is what I'm trying to execute throught he Command Prompt,
bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
Downloads\output.txt" -T -c -Sqisdevsql1
I'm running this from our development server, which is not where SQL Server
lives, we have a dedicated SQL Server box, qisdevsql1.
What am I doing wrong?This works on my machine. Can you run bcp -v from a command window and see
what you get?
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"DaRock" <DaRock@.discussions.microsoft.com> wrote in message
news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
> First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
> this newsgroup so forgive me if I should have posted this question else
> where.
> I'm trying to use bcp to output data from a table to a file but keep
> getting
> the error, "An error occurred while trying to process the command line."
> This is what I'm trying to execute throught he Command Prompt,
> bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
> I'm running this from our development server, which is not where SQL
> Server
> lives, we have a dedicated SQL Server box, qisdevsql1.
> What am I doing wrong?
>|||I get, BCP - Bulk Copy Program, some registration info and then Version
9.00.1399.06.
Troy
"Hilary Cotter" wrote:

> This works on my machine. Can you run bcp -v from a command window and see
> what you get?
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "DaRock" <DaRock@.discussions.microsoft.com> wrote in message
> news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
>
>|||> bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
Since your database name does't confirm to the rules for identifiers, you
need to enclose the name in square brackets:
bcp [450_gilroy].dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
Downloads\output.txt" -T -c -Sqisdevsql1
Hope this helps.
Dan Guzman
SQL Server MVP
"DaRock" <DaRock@.discussions.microsoft.com> wrote in message
news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
> First of all I'm brand new to SQL Server (fresh off 7 years of Sybase) and
> this newsgroup so forgive me if I should have posted this question else
> where.
> I'm trying to use bcp to output data from a table to a file but keep
> getting
> the error, "An error occurred while trying to process the command line."
> This is what I'm trying to execute throught he Command Prompt,
> bcp 450_gilroy.dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
> I'm running this from our development server, which is not where SQL
> Server
> lives, we have a dedicated SQL Server box, qisdevsql1.
> What am I doing wrong?
>|||Yes that was it. Thanks!
"Dan Guzman" wrote:

> Since your database name does't confirm to the rules for identifiers, you
> need to enclose the name in square brackets:
> bcp [450_gilroy].dbo.temp_rim out "C:\Program Files\AutoMate\AutoMate
> Downloads\output.txt" -T -c -Sqisdevsql1
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "DaRock" <DaRock@.discussions.microsoft.com> wrote in message
> news:81457C76-EC2B-468A-B8CF-290B396076BB@.microsoft.com...
>
>

BCP Error Message

Hi All,
I am getting the below error message when I am executing the BCP command
BCP command
==========
xp_cmdshell 'c:\MSSQL7\BINN\BCP SQLManager.dbo.z_DBAdmin_Fwd_MAXDRBUS02_DBAdmin_db o_tbl_CheckServerRoleMembers_20040331161058 in "c:\Temp\DBAdmin_Fwd_MAXDRBUS02_DBAdmin_tbl_CheckS erverRoleMembers.bcp" /SSQLSER /UDUser /Ptest /c /b1000 /m1'
Error Message
==========
SQLState = 08001, NativeError = 6
Error = [Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server not found.
SQLState = 01000, NativeError = 53
Warning = [Microsoft][ODBC SQL Server Driver][Named Pipes]ConnectionOpen (CreateFile()).
Thanks & Regards
Balaji
Balaji (anonymous@.discussions.microsoft.com) writes:
> I am getting the below error message when I am executing the BCP command
> BCP command
>==========
> xp_cmdshell 'c:\MSSQL7\BINN\BCP SQLManager.dbo.z_DBAdmin_Fwd_MAXDRBUS02_DBAdmin_db o_tbl_CheckServerRoleMembers_20040331161058 in "c:\Temp\DBAdmin_Fwd_MAXDRBUS02_DBAdmin_tbl_CheckS erverRoleMembers.bcp" /SSQLSER /UDUser /Ptest /c /b1000 /m1'
> Error Message
>==========
> SQLState = 08001, NativeError = 6
> Error = [Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server not found.
> SQLState = 01000, NativeError = 53
> Warning = [Microsoft][ODBC SQL Server Driver][Named Pipes]ConnectionOpen (CreateFile()).
That means that BCP cannot find the server you are trying to connect to.
Why it cannot do so, I have no idea. To start with, you have not provided
any information on why you should be able to connect to this server.
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp