First, I'm new. I'm on SQL Server 2008 R2. I have a bulk insert script that works. I tried to create a stored procedure and then save it as a storedprocedure.sql
. Ultimately, I need a .bat
file to launch the bulk insert. I have another program that can run external programs but it only sees .bat
or .exe
.
So, here is my bulk insert script:
Bulk Insert MyDatabase.dbo.cust_adj
From 'C:\path\importformat.txt'
With
(
FieldTerminator= '|',
Rowterminator= '\n'
)
Go
(this works)
I then tried to create the stored procedure:
Create Procedure LoadDailyAdjReport
AS
Bulk Insert MyDatabase.dbo.cust_adj
From 'C:\path\importformat.txt'
With
(
FieldTerminator= '|',
Rowterminator= '\n'
)
Go
It said it made it successfully... but I don't know how to check it.
So then I tried making a .bat file and tried:
@echo off
sqlcmd -S MyServer\MyDataBase -i C:\mypath\Load_Daily_Adjustment.sql
It doesn't work. At first I thought it was my .bat instructions (which probably aren't right) but then I wondered if my stored procedure was right. The problem is that I really don't know enough to troubleshoot this. Could someone please offer some advice or pointers on what this should be like?
Thank you ever so much.
Ok, on the SQL Server this .bat file works:
sqlcmd -S MyServerName -E -d MyDatabase -Q "EXEC MyStoredProcedure"
The server is let's say: \Server1\ My program to run the bat file is on another server. The file is shared, the user has security to SQL, to Folder, to program, etc.
How would I change the .bat file to be on the server of the program?
So, on Server2 I want to have the bat file that accesses and opens the .bat on Server1. To do that, do I need to change the .bat file to have the path of \Server1\PathName\File.bat?