首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

小弟我想用BULK INSERT 导入十几万条的文本记录哪位高手可以指教一下

2013-08-06 
我想用BULK INSERT 导入十几万条的文本记录谁可以指教一下我想用BULK INSERT 导入十几万条的文本记录表结

我想用BULK INSERT 导入十几万条的文本记录谁可以指教一下
我想用BULK INSERT 导入十几万条的文本记录
表结构为

CREATE TABLE [dbo].[pySY](
[ARSN] [char](5) NOT NULL,
[PID] [char](8) NOT NULL,
[TIM] [char](14) NULL,
[DCDS] [char](1) NULL,
[SPT] [char](8) NULL,
[SRT] [char](8) NULL,
[TPC] [char](10) NULL,
[TRC] [char](10) NULL,
[LSN] [char](8) NOT NULL,
[DS] [char](128) NULL,
[SendTag] [int] NOT NULL,
 CONSTRAINT [PK_pySY] PRIMARY KEY CLUSTERED 
(
[SendTag] ASC,
[PID] ASC,
[ARSN] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

表有十二列,最后一列是不能空值

文本文件为
26640001126220130730223737100000446000000000000540.600000000.000031938100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
024690001126320130730230143100000264000000000000216.400000000.000021971800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
022380001126420130730173434100000116000000000000055.600000000.000023909000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
023990001126620130730224334100000401000000000000431.200000000.000028072400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
021730001126820130730221938100000413000000000000408.000000000.000031876700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
025390001126920130730185833100000174000000000000171.200000000.000028294200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
025520001127020130730231658100000446000000000000434.200000000.000028030900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
026240001127220130730223617100000084000000000000074.200000000.000015060900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

文本只有十一列
请问用BULK INSERT 语句应该怎样导入表中


[解决办法]
是会快很多,问题是网上大把例子,你试过没?另外哪些规则,你可以考虑先把表中not null的条件去掉,导入后再处理。
[解决办法]
建个11列的中间表,BULK INSERT到中间表,然后插入目标表..


 insert into [dbo].[pySY]
  select *,[末列的值] from [中间表]

[解决办法]
--给最后一列加个默认值
ALTER TABLE pySY
 ADD CONSTRAINT DF_pySY_SendTag DEFAULT(0)
 FOR SendTag

[解决办法]
http://blog.csdn.net/htl258/article/details/4548556我没试过,找给帖子给你试试

热点排行