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

2012年3月19日星期一

BCP newbie question

I am trying to run the bcp utility. When I run it from the command prompt it
works. When I try it from a bat it goes into this crazy endless loop
repeating the command again and again. Any ideas what I am doing wrong?
Regards, Chris.
bcp pubs..publishers out C:\test.txt -c -U****** -P***** -S******
pause
Is your command file by chance named BCP.BAT or BCP.CMD? In that case, it's
calling itself rather than BCP.EXE. You can remedy the problem by
specifying BCP.EXE and/or using a different name for you command file. It's
a good practice to avoid naming command files the same as EXE or command
names.
Hope this helps.
Dan Guzman
SQL Server MVP
"Chris" <123@.123.com> wrote in message
news:OO3%23CBbLGHA.1124@.TK2MSFTNGP10.phx.gbl...
>I am trying to run the bcp utility. When I run it from the command prompt
>it
> works. When I try it from a bat it goes into this crazy endless loop
> repeating the command again and again. Any ideas what I am doing wrong?
> Regards, Chris.
> bcp pubs..publishers out C:\test.txt -c -U****** -P***** -S******
> pause
>

BCP newbie question

I am trying to run the bcp utility. When I run it from the command prompt it
works. When I try it from a bat it goes into this crazy endless loop
repeating the command again and again. Any ideas what I am doing wrong?
Regards, Chris.
bcp pubs..publishers out C:\test.txt -c -U****** -P***** -S******
pauseIs your command file by chance named BCP.BAT or BCP.CMD? In that case, it's
calling itself rather than BCP.EXE. You can remedy the problem by
specifying BCP.EXE and/or using a different name for you command file. It's
a good practice to avoid naming command files the same as EXE or command
names.
Hope this helps.
Dan Guzman
SQL Server MVP
"Chris" <123@.123.com> wrote in message
news:OO3%23CBbLGHA.1124@.TK2MSFTNGP10.phx.gbl...
>I am trying to run the bcp utility. When I run it from the command prompt
>it
> works. When I try it from a bat it goes into this crazy endless loop
> repeating the command again and again. Any ideas what I am doing wrong?
> Regards, Chris.
> bcp pubs..publishers out C:\test.txt -c -U****** -P***** -S******
> pause
>

BCP newbie question

I am trying to run the bcp utility. When I run it from the command prompt it
works. When I try it from a bat it goes into this crazy endless loop
repeating the command again and again. Any ideas what I am doing wrong?
Regards, Chris.
bcp pubs..publishers out C:\test.txt -c -U****** -P***** -S******
pauseIs your command file by chance named BCP.BAT or BCP.CMD? In that case, it's
calling itself rather than BCP.EXE. You can remedy the problem by
specifying BCP.EXE and/or using a different name for you command file. It's
a good practice to avoid naming command files the same as EXE or command
names.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Chris" <123@.123.com> wrote in message
news:OO3%23CBbLGHA.1124@.TK2MSFTNGP10.phx.gbl...
>I am trying to run the bcp utility. When I run it from the command prompt
>it
> works. When I try it from a bat it goes into this crazy endless loop
> repeating the command again and again. Any ideas what I am doing wrong?
> Regards, Chris.
> bcp pubs..publishers out C:\test.txt -c -U****** -P***** -S******
> pause
>

2012年2月25日星期六

bcp command

Hi all,

I am trying to run a .bat file with this bcp command.

BCP "database.dbo.state" OUT "C:\TEMP\state.dat" -SServerName -U"userid" -P"password" -m1 -n -a65536 -E -q

However, it is not producing me a file as I expected.

Is there any other configuration I need to set before it work?

Any help would appreciated.What error messages are being produced? I don't think I've seen BCP fail silently in years. Have you ever done a successful BCP against that SQL Server from the same client maching?

-PatP|||The error is: "Error in attempting to load a pair of translation tables."|||The error is: "Error in attempting to load a pair of translation tables."

Excuse me?

Is it not creating a file, or not creating a file as "expected'

Because if it's the latter and you expect to "see" data, you won't. It's in native format.

You need to lose the -n and use -c|||The error is: "Error in attempting to load a pair of translation tables."That is definitely not an error message generated by BCP. What other programs are you running that might have generated that message?

-PatP

2012年2月13日星期一

Batch files

Is there a way to run sql queries using a bat file. I
have some bat files I currently have scheduled to run and
would like to run some queries inside of it.
Thanks,
RandyRandy,
Refer 'osql' in BooksOnLine.
--
Dinesh.
SQL Server FAQ at
http://www.tkdinesh.com
"Randy" <sparks70b@.yahoo.com> wrote in message
news:0c1401c35d01$5a6bcab0$a601280a@.phx.gbl...
> Is there a way to run sql queries using a bat file. I
> have some bat files I currently have scheduled to run and
> would like to run some queries inside of it.
> Thanks,
> Randy

batch file help

I wish to have a batch file(test.bat) that does an OSQL as below. The OSQL
statement below needs some modification as well.
OSQL -E -S%1 -Q"select @.@.servername" -oc:\xyz\%1output.txt
When i enter test.bat, i want it to prompt for servername so i can add it at
the prompt
Also i would like the prompted servername to be filled in %1 parameter in
the OSQL . Can this be done ?Hi Hassan,
This is not the right place to ask any batch file related questions.
Anyway try this ....
You can specify server name in the command propmt. If you haven't specify
the server name in the command prompt it will prompt for it.
Regards,
Suhanthan, V.
suhan@.jhc.lk
----
@.ECHO OFF
IF NOT _%1_ == __ GOTO WITHPARAM
GOTO WITHOUTPARAM
:WITHPARAM
OSQL -E -S%1 -Q"select @.@.servername" -oc:\xyz\%1output.txt
GOTO EXITTHIS
:WITHOUTPARAM
SET /P SERVER="Enter SQL server name :"
OSQL -E -S%SERVER% -Q"select @.@.servername" -oc:\xyz\%1output.txt
SET SERVER=
:EXITTHIS
----
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:O2$uiVRnDHA.1084@.tk2msftngp13.phx.gbl...
> I wish to have a batch file(test.bat) that does an OSQL as below. The OSQL
> statement below needs some modification as well.
> OSQL -E -S%1 -Q"select @.@.servername" -oc:\xyz\%1output.txt
> When i enter test.bat, i want it to prompt for servername so i can add it
at
> the prompt
> Also i would like the prompted servername to be filled in %1 parameter in
> the OSQL . Can this be done ?
>
>

2012年2月12日星期日

batch (.bat) file from sql server?

Is that possible to run batch file (.bat) from sql server?
Thanks.
*** Sent via Developersdex http://www.examnotes.net ***DECLARE @.v_cmd VARCHAR(2000)
SET @.v_cmd = 'CALL "d:\myfolder\mybatch.bat"'
EXEC master..xp_cmdshell @.v_cmd ,NO_OUTPUT
-- OR
-- EXEC master..xp_cmdshell @.v_cmd|||I guess what I am asking is to call the bat file from a stored proc?
*** Sent via Developersdex http://www.examnotes.net ***|||Thanks.
*** Sent via Developersdex http://www.examnotes.net ***|||Test Test (farooqhs_2000@.yahoo.com) writes:
> I guess what I am asking is to call the bat file from a stored proc?
You can invoke a bat file with help of xp_cmdshell. Note that xp_cmdshell
is fairly dangerous feature, if opened to unprivileged users, since
it permits you run commands on Windows level on the SQL Server machine.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx