cmd모드에서 바로 *.vbs 실행기키기
C:\WINDOWS\system32\cscript.exe 를 이용해서 실행되는 것이다.
저장은 *.vbs로 한다. cmd모드에서 해당 화일을 실행하면 바로 실행이 된다.
아래 내용은 테이블에 2004년부터 2014년까지의 날짜가 쭈욱 들어간다.
이거 잘 만 이용하면 물건이 될거 같다.
Function FormatINT(intValue, intspace)
dim lenValue
dim diff
lenValue = Len(CStr(intValue))
diff = intSpace - lenValue
If diff > 0 Then
formatInt = String(diff,"0") & intValue
Else
formatInt = intValue
End If
End Function
constr = "Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=;Initial Catalog=test;Data Source=127.0.0.1"
Set Con = WScript.CreateObject("ADODB.Connection")
Con.Open constr
startDate = CDate("2004-01-01")
endDate = CDATE("2014-12-31")
tempDate = startDate
WScript.Echo tempDateStr
Do While True
tempDateStr = Replace(tempDate,"-","")
SQL = "INSERT INTO DIC_DATE(PDATE, PYEAR, PMONTH, PDAY, YDAYS, PQUARTER, YWEEKS, PWEEK, ISHOLIDAY, DAYDESC) " &_
"VALUES('"& tempDateSTR & "','" &_
FormatInt(Year(tempDate),4) & "','" &_
FormatInt(Month(tempDate),2) & "','" &_
FormatInt(Day(tempDate),2) & "'," &_
Datepart("y",tempDate) & "," &_
Datepart("q",tempDate) & "," &_
Datepart("ww",tempDate) & "," &_
Datepart("w",tempDate) & ",0,'') "
Con.Execute(sql)
WScript.Sleep 10
if DateDiff("d",tempDate, endDate) <= 0 Then Exit Do
tempDate = DateAdd("d",1,tempDate)
Loop
Con.Close
Set Con = Nothing