Right String Truncation in SQLServer 2000 
Author Message
 Right String Truncation in SQLServer 2000

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

If oFS.FileExists(FileSpec) Then
BC.DataFilePath = FileSpec
MsgBox "** File " & FileSpec & " does not exist", vbCritical, "Error in
End If
Set oTable = oDB.Tables(TableName)
oTable.ImportData BC


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?


Sat, 24 Sep 2005 03:32:54 GMT  
 [ 1 post ] 

 Relevant Pages 

1. 01004 - 0 - [Microsoft][ODBC SQL Server Driver]String data, right truncation

2. -2147217889 [ODBC SQL Server Driver] String Data, Right Truncation

3. Getting ADO Error- String Truncation

4. Getting ADO Error - String Truncation

5. string truncation with crystal reports 8.5 and sql server 7

6. String Truncation

7. Truncation Issue w/ Strings

8. SQLServer 2000 + VB.NET + DTS

9. VB6 + SQLserver 2000: Connection.execute result sets

10. Oracle to SQLserver 2000

11. Problem updating record in SQLServer 2000 using VB5

12. ADO 2.6 problem Can't read BLOB data from Sqlserver 2000 table


Powered by phpBB® Forum Software