question

Paul 5 avatar image
Paul 5 asked

SQL Server Connection

Trying to create a batch file that connects to a SQL Server from a schedule task on a server. I am new at the SQL game. Any one now a good example of batch file for this ? I run auotimport.bat to call raddbconnection and then import the paudit.dat into the SQL database rad_db into table PAUDIt. Here is what i have so far. Help ?

Autoimport.bat:

                    
CALL raddbconnection.bat                    
BULK                    
INSERT PAUDIT                    
FROM X:\RIS\SQLDB\PAUDIT.DAT                    
WITH                    
(                    
FIELDTERMINATOR = ',',                    
ROWTERMINATOR = '\n'                    
)                    
GO                    

raddbconnectionbat:

                    
@Echo ON                    
Data Source=UKH-SQLCL2VS2\CL2VS2;Initial Catalog=RAD_DB;User Id=;Password=;                    

Errors when runing:

                    
H:\pgreer\My Documents>CALL raddbconnection.bat                    
                    
H:\pgreer\My Documents>Data Source=UKH-SQLCL2VS2\CL2VS2;Initial Catalog                    
ser Id=;Password=;                    
'Data' is not recognized as an internal or external command,                    
operable program or batch file.                    
                    
H:\pgreer\My Documents>BULK                    
'BULK' is not recognized as an internal or external command,                    
operable program or batch file.                    
                    
H:\pgreer\My Documents>INSERT PAUDIT                    
'INSERT' is not recognized as an internal or external command,                    
operable program or batch file.                    
                    
H:\pgreer\My Documents>FROM 'X:\RIS\SQLDB\PAUDIT.DAT'                    
'FROM' is not recognized as an internal or external command,                    
operable program or batch file.                    
                    
H:\pgreer\My Documents>WITH                    
'WITH' is not recognized as an internal or external command,                    
operable program or batch file.                    
                    
H:\pgreer\My Documents>(                    
FIELDTERMINATOR = ',',                    
ROWTERMINATOR = '\n'                    
)                    
'FIELDTERMINATOR' is not recognized as an internal or external command,                    
operable program or batch file.                    

Your post will show up soon

sql-server-2005data-import
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.