
Right String Truncation in SQLServer 2000
Hi,
I am importing text files into a table in SQL Server 2000 from Visual
Basic 6.0, using the Bulk Copy (BC) object. When the text data is too
long for the field, I would like BC to perform a right truncation
without producing a VB6 runtime error. Is there an option somewhere that can
be set to do the truncation without producing the runtime error?
Here is the function that I have written to import the file (FileSpec) into
the table (TableName):
Private Sub ImportFile2Table(oDB As SQLDMO.Database, FileSpec As String,
TableName As String)
Dim oTable As SQLDMO.Table
Dim BC As New BulkCopy
Dim oFS As New FileSystemObject, oFile As File
BC.DataFileType = SQLDMODataFile_SpecialDelimitedChar
BC.ColumnDelimiter = "|"
BC.RowDelimiter = vbCrLf
BC.SetCodePage SQLDMOBCP_RAW
If oFS.FileExists(FileSpec) Then
BC.DataFilePath = FileSpec
Else
Beep
Beep
MsgBox "** File " & FileSpec & " does not exist", vbCritical, "Error in
ImportFile2Table"
End If
Set oTable = oDB.Tables(TableName)
oTable.ImportData BC
oTable.Refresh
DoEvents
Set oTable = Nothing
Set oFS = Nothing
End Sub
Is there a BC.Property that would allow the imported file to be
automatically truncated without issuing a VB runtime error?
Thnx