BulkCopy Problem
May 9, 2007
Hello,
I am using bcp in a stored procedure. I am calling the stored procedure with VB.NET 2.0. The stored procedure does work, but not every time. I can run the stored procedure from Server Manager Express, and it does run, but not every time.
Here is my bcp command. Is this correct?
set @cmd = 'bcp '+@dbname+'.dbo.'+@tablename+' '+@direction+' '+@filepath+' -T -c -S .SQLEXPRESS'
exec master..xp_cmdshell @cmd
Thanks for any ideas on how to debug this.
Tom
View 5 Replies
Jul 20, 2005
Hi all I am trying to do a Bulk Copy from a "tab delmimited" text file to atable in my database. I have it almost working except when the file hastoo few columns for the table (table has 421 columns).Some of my the files will have 419 columns some others files will have 421columns.When my bulk insert script encounters a file with 419 colums it will putsome of the data from the next line in the last 2 columns.I tried creating a DTS package with a bulk insert and I get the same outcome.Here is my test script can anyone help'--------------------------------------------------------------<%Dim objServer: Set objServer = Server.CreateObject("SQLDMO.SQLServer")Dim objBCP: Set objBCP = Server.CreateObject("SQLDMO.BulkCopy")Dim objDB: Set objDB = Server.CreateObject("SQLDMO.Database")dim BulkCopydim objTabledim itemdim g_strUploadPath: g_strUploadPath =Server.MapPath("../DOC2/")&"upload"dim strFileName: strFileName = g_strUploadPath & "ex_test.txt"'if file doesn't exist and it's an import,'don't waste time (too be add later)'If Import = True And Dir(FileName) = "" Then Exit Function'On Error GoTo ErrorHandlerobjServer.Connect "XXX.XXX.XX.XX", "XXX", "XX"objServer.EnableBcp = 1Set objDB = objServer.Databases("Advia120v2_dev")With objBCP.DataFilePath = strFileName.UseBulkCopyOption = True'tab delmitted, carriage return line feed ends row.DataFileType = 2'.ColumnDelimiter = chr(9)'.RowDelimiter = chr(13) & chr(10).IncludeIdentityValues = FalseEnd WithobjDB.Tables("Hemo_193_39552_39").ImportData objBCP'BCP = True'ErrorHandler:'Set objBCP = Nothing'Set objServer = Nothing%>'--------------------------------------------------------------thanks
View 3 Replies
View Related
Dec 8, 2007
Hi Folks,
Is there any effcent way of copy bulk records from SQL2000 to SDF ? The approach I am using at moment is manually concatenate insert CommandText based on the value datatable from SQL 2000. However, it's not very effcient and I am getting timeout on a table that has around 30 fields and 3,600 records.
Can any one think a better way of doing bulk insert on SDF? Both schema on SQL 2000 and SDF are exactly the same.
Thanks
View 8 Replies
View Related
Nov 11, 2007
I'm trying to use the SQL Bulk copy class to bulk import from a text file.I'm getting the following error: Line 24: bulkCopy.WriteToServer(CreateDataTableFromFile()); System.Data.SqlClient.SqlException: An error has occurred while establishing a
connection to the server. When connecting to SQL Server 2005, this failure may
be caused by the fact that under the default settings SQL Server does not allow
remote connections. (provider: Named Pipes Provider, error: 40 - Could not open
a connection to SQL Server) I've even tried to allow remote connections thro pipes and restarted the database engine but to no avail. Any inputs/suggestions?
View 3 Replies
View Related
Aug 22, 2005
Hi,I'm trying to find out if we can use bulkcopy via odbc in sql server 2005.With sql server 200 we could use the odbcbcp.dll.I can not find any info regarding this for ms sql server 2005.Thanks,Jos van der Velden
View 1 Replies
View Related
Dec 9, 2007
I use SQLDMO.Bulkcopy in an VB6 (have to) program to load data from aplain text file into a SQL Server 2000.One of the target columns is NOT NULL but it happens that I receive amissing value for that column in the source file. BulkCopy then has anODBC error raised that complains about the violated NOT NULLconstraint. The Bulkcopy error file however is empty. Is there a wayto figure out in which row of the source file the error occured ?Maybe a call to some ODBC diagnostics method to receive furtherinformation ? I'd like to avoid the obvious solution to drop theconstraint and then query the loaded data for NULL values.ThanksNils
View 3 Replies
View Related