@ECHO off
cls
REM ECHO on
REM Objective: To upload all the files in the folder to SQL server as a table
REM Created by: MAK
REM Date: Nov 3, 2004
REM Contact: mak_999@yahoo.com
REM Check parameters
if "%1"=="" Goto noparmErr
if "%1"=="/?" Goto Help
REM assign variables
set Sourcefolder=%1
set servername=%2
set Databasename=%3
set loginname=%4
set password=%5
set LogFile=%6
Date/t > %6
time /t >> %6
REM Export DIR listing to Dirlist.txt
dir %1 /b > Dirlist.txt
OSQL /S%2 /U%4 /P%5 /d%3 /Q "if exists (select * from %3.dbo.sysobjects where id = object
_id(N'[Myuploadtable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table %3.dbo.[Myuploadtable] " >> %6
OSQL /S%2 /U%4 /P%5 /d%3 /Q "create table %3.dbo.Myuploadtable (id varchar(500),ImageFiles Image)" >> %6
FOR /F "usebackq delims==" %%i in (Dirlist.txt) do OSQL /S%2 /U%4 /P%5 /Q "insert into %3.dbo.Myuploadtable (id,ImageFiles) values('%%i',' ') " >> %6
FOR /F "usebackq delims==" %%i in (Dirlist.txt) do textcopy.exe /S%2 /U%4 /P%5 /D%3 /Tmyuploadtable /CImagefiles /F"%1%%i" /I /W"where [id]='%%i'" >> %6
GOTo END2
:noparmErr
Echo Usage help: example as follows
echo ...
Echo Objective: To upload all the files in the folder to SQL server Table
Echo Created by: MAK
Echo USAGE:
ECHO ....
ECHO ....
Echo %0 SourceFolder Servername Databasename Login Password LogFile
Goto END2
:Help
Echo Usage help: example as follows
echo ...
Echo Objective: To upload all the files in the folder to SQL server Table
Echo Created by: MAK
Echo USAGE:
ECHO ....
ECHO ....
Echo %0 SourceFolder Servername Databasename Login Password Logfile
Goto END2
:END
Echo "Compare Query results Completed" >>%LogFile%
date/t >> %LogFile%
time/t >> %LogFile%
goto END2
:END2