October 9, 2009 at 10:59 am
I have a .csv file separated whit ';' but in the last column it doesnt inserting any data, why is that?
Codes:
BULK INSERT CallList_Prueba FROM 'C:\Prueba.csv' WITH ( FIRSTROW = 2, FIELDTERMINATOR = ';', ROWTERMINATOR = '\r', FIRE_TRIGGERS )"
and the Prueba.csv have the following info:
I3_RowID;PHONENUMBER;Zone;Status;IC_Value3;Attempts;Counter;I3_AttemptsAbandoned;I3_AttemptsMachine;I3_AttemptsBusy;I3_AttemptsFax;I3_AttemptsNoAnswer;MoneyCounter;Fecha;Tabla;Cliente;Sede
1;2770055;;;;;;;;;;;;;;;;;
2;2770064;;;;;;;;;;;;;;;;;
3;2770111;;;;;;;;;;;;;;;;;
4;2770143;;;;;;;;;;;;;;;;;
5;2770500;;;;;;;;;;;;;;;;;
6;2770529;;;;;;;;;;;;;;;;;
and the table is:
CREATE TABLE [dbo].[CallList_Prueba] (
[I3_RowID] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[PhoneNumber] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Zone] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Status] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ICValue3] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Attempts] [int] NULL ,
[Counter] [int] NULL ,
[I3_AttemptsAbandoned] [int] NULL ,
[I3_AttemptsMachine] [int] NULL ,
[I3_AttemptsBusy] [int] NULL ,
[I3_AttemptsFax] [int] NULL ,
[I3_AttemptsNoAnswer] [int] NULL ,
[MoneyCounter] [money] NULL ,
[Fecha] [datetime] NULL ,
[Tabla] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Sede] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Cliente] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CallList_Prueba] WITH NOCHECK ADD
CONSTRAINT [PK_CallList_Prueba] PRIMARY KEY CLUSTERED
(
[I3_RowID]
) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
ALTER TABLE [dbo].[CallList_Prueba] WITH NOCHECK ADD
CONSTRAINT [DF_CallList_Prueba_Zone] DEFAULT ('PCF') FOR [Zone],
CONSTRAINT [DF_CallList_Prueba_Status] DEFAULT ('') FOR [Status],
CONSTRAINT [DF_CallList_Prueba_ICValue3] DEFAULT ('CAMP_EPM_EMPRESARIAL_PORTAL_VIP') FOR [ICValue3],
CONSTRAINT [DF_CallList_Prueba_Fecha] DEFAULT (getdate()) FOR [Fecha],
CONSTRAINT [DF_CallList_Prueba_Tabla] DEFAULT ('CallList_Prueba') FOR [Tabla],
CONSTRAINT [DF_CallList_Prueba_Sede] DEFAULT ('Poblado') FOR [Sede],
CONSTRAINT [DF_CallList_Prueba_Cliente] DEFAULT ('Salida_EPM') FOR [Cliente]
GO
Thanks any help.
October 9, 2009 at 11:23 am
I have noticed that the problem is whit asp.Net calling the Bulk Insert, i do the query and In managment studi it works, but whit .NET couses that problem.
public int AlmacenarDatosCallList(string Ruta, string Tabla)
{
string strConexion = ConfigurationSettings.AppSettings["conexion"];
SqlConnection con = new SqlConnection(strConexion);
string Creacion = "BULK INSERT " + Tabla +
" FROM '" + Ruta + "' " +
" WITH ( FIRSTROW = 2, FIELDTERMINATOR = ';', ROWTERMINATOR = '', FIRE_TRIGGERS )";
con.Open();
SqlCommand command = new SqlCommand(Creacion, con);
int Resul = command.ExecuteNonQuery();
con.Close();
if (Resul != 0)
return 1;
else
return 0;
}
Thank you, ill search the causes.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply