May 27, 2008 at 10:02 am
I have a batch file that executes the BCP command.Now i just want to execute a store procedure with two date input parameters from BCP. The store procedure is working fine in Query Analyser. I just want to execute it from BCP that is in batch file.
thank you
May 27, 2008 at 11:53 am
manaprime (5/27/2008)
I have a batch file that executes the BCP command.Now i just want to execute a store procedure with two date input parameters from BCP. The store procedure is working fine in Query Analyser. I just want to execute it from BCP that is in batch file.thank you
Take a look at the SQLCMD utility. Using it from command line you can connect to SQL server and execute stored procedure or issue an ad hoc queries.
Good Day,
Bulent
May 27, 2008 at 12:45 pm
Use SQLCMD as mentioned. BCP doesn't run stored procedures.
May 27, 2008 at 1:22 pm
You want either osql or SQLCMD and the -Q option for either.
BCP will only execute a query for bulk loading or unloading tables.
Your friendly High-Tech Janitor... 🙂
May 27, 2008 at 4:50 pm
Ummm... BCP can execute an "EXEC" as part of that query...
--Jeff Moden
Change is inevitable... Change for the better is not.
May 27, 2008 at 5:11 pm
BCP.exe does support providing a select statement or the execution of a stored procedure in addition to specifying a table. Suggest that the stored procedure name be fully qualified.
Here is the results of a test with SQL Server 2008:
C:\>bcp.exe "exec [AdventureWorks].[dbo].[uspGetEmployeeManagers] @EmployeeID = 153" queryout "c:\EmployeeManagers.txt"
-SCFEDERL -T -c
Starting copy...
4 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1 Average : (4000.00 rows per sec.)
SQL = Scarcely Qualifies as a Language
May 27, 2008 at 11:06 pm
Hi.
Thanx for reply i am just running this in batch file
bcp"exec [DBNAME].[dbo].[SProcName]" queryout \\Severname\Projects\temp.CSV -S ServerName -U sa -P -t, -C
but i am getting this error message
bcp is not recognized as an internal or external command, operable program or batch file
May 28, 2008 at 6:45 am
Not sure why the dilema... error message says what's wrong. You've either not installed it when you installed SMS or it's simply not available on the machine that you're using or there's no path to it. Perhaps someone screwed up and didn't install it or deleted it from the server, as well.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply