Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problem whit Bulk Insert

Author  Topic 

Kandu12
Starting Member

1 Post

Posted - 2009-12-09 : 12:05:20
Im doing a bulk insert query whit a csv file. The table im doing the bulk insert have constraints and by default puts a values on some columns, here is the table:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CallList_CONTACT_Prueba_Aplicativo_Dic04](
[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 CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_Zone] DEFAULT ('PCF'),
[Status] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_Status] DEFAULT (''),
[IC_Value3] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_ICValue3] DEFAULT ('CAMP_CONTACT_PRUEBA_APLICATIVO'),
[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 CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_Fecha] DEFAULT (getdate()),
[Tabla] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_Tabla] DEFAULT ('CallList_CONTACT_Prueba_Aplicativo_Dic04'),
[UseDialPlan] [tinyint] NULL CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_DialPlan] DEFAULT ('1'),
[Cliente] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_Cliente] DEFAULT ('Salida_CONTACT'),
[Sede] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CallList_CONTACT_Prueba_Aplicativo_Dic04_Sede] DEFAULT ('Poblado'),
CONSTRAINT [PK_CallList_CONTACT_Prueba_Aplicativo_Dic04] PRIMARY KEY CLUSTERED
(
[I3_RowID] ASC
) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF


But the problem is when i do the bulk insert put nulls values on the columns that have by default other values:

BULK INSERT CallList_CONTACT_Prueba_Aplicativo_Dic04
FROM '\\ip\Temporal\Camp_Prueba_SinEspacios.csv'
WITH ( CHECK_CONSTRAINTS, FIRSTROW = 2, FIELDTERMINATOR = ';', ROWTERMINATOR = '', FIRE_TRIGGERS )

the data that im trying to import in the .CVS file is:

I3_RowID;PHONENUMBER;Zone;Status;IC_Value3;Attempts;Counter;I3_AttemptsAbandoned;I3_AttemptsMachine;I3_AttemptsBusy;I3_AttemptsFax;I3_AttemptsNoAnswer;MoneyCounter;Fecha;Tabla;UseDialPlan;Cliente;Sede}223;2770055;;;;;;;;;;;;;;;;
224;2770064;;;;;;;;;;;;;;;;
225;2770111;;;;;;;;;;;;;;;;
226;2770143;;;;;;;;;;;;;;;;
227;2770500;;;;;;;;;;;;;;;;

those values that is in blank in the columns that have constraints by default should put a value but it doesnt working.

i notice that it apear 2 times the insert message, why is that? could this be the problem?

(5 row(s) affected)

(5 row(s) affected)

Thank you any help.
   

- Advertisement -