Wednesday, May 31, 2006

Copy file and add time to name

' Copy File
' Option Explicit

Function Main()

Dim oFSO
Dim sSourceFile
Dim sDestinationFile
Dim sdate
sdate = CStr(Year(Date)) & CStr(Month(Date)) & CStr(Day(Date))



Set oFSO = CreateObject("Scripting.FileSystemObject")

sSourceFile = "\\Server\C$\importexport\File_Name.asc"
sDestinationFile = "\\ Server\d$\DBA\ Archive\File_Name" & sdate &".asc"
'MsgBox( sDestinationFile)


oFSO.CopyFile sSourceFile, sDestinationFile

' Clean Up
Set oFSO = Nothing

Main = DTSTaskExecResult_Success
End Function

Tuesday, May 30, 2006

YYYYMM

SUBSTRING(CONVERT(varchar(8), [Date], 112), 1, 6) AS YYYYMM,

Thursday, May 18, 2006

VBScript Functions

VBScript Functions: "VBScript Functions

--------------------------------------------------------------------------------

This page contains all the built-in VBScript functions. The page is divided into following sections:

Date/Time functions
Conversion functions
Format functions
Math functions
Array functions
String functions
Other functions
"

VBScript - VB Script in DTS - Else Elseif

VBScript - VB Script in DTS: "Im trying to use ActiveX within a DTS package. What I'm trying to do is us bit of simply VBScript to transmit data from one data source to another.

Example:


Function Main()
IF

DTSSource('Type') = 1

Then

DTSDestination('Type') = 'P1'

Else

DTSDestination('Type') = 'Other'

End If

Main = DTSTransformStat_OK
End Function


However this doesnt seem to work. Can anyone explain why this might be.

Cheers



Tek-Tips Forums is Member Supported. Click Here to donate.
mrmovie (TechnicalUser)14 Dec 05 6:22
can you confirm that
DTSSource('Type') actually returns something you can convert to a string?
this DTSSource('Type') statement doesnt make any sense to me.

if doesnt look like you pass anything to your function and your function appears to return something which isnt defined within the function, again i am not sure i understand this


NotSQL (TechnicalUser)14 Dec 05 6:28
Its ok i've got it to work... Thanks Though.


IF DTSSource('Type') = 1 Then

DTSDestination('Type') = 'P1'

Elseif DTSSource('Type') = 2 Then

DTSDestination('Type') = 'P2'

Elseif DTSSource('Type') = 3 Then

DTSDestination('Type') = 'P3'

Elseif DTSSource('Type') = 4 Then

DTSDestination('Type') = 'P4'

Elseif DTSSource('Type') = 5 Then

DTSDestination('Type')"