就这样写入???--> 测试数据:[TB] if object_id('[TB]') is not null drop table [TB] create table [TB]([col1] int,[col2] varchar(10),[col3] int) insert [TB] select 12334,'xj77334245',36066316 union all select 12333,'xj35822317',28682165 union all select 12332,'xj67832286',26574366 union all select 12331,'xj15427944',74060125 union all select 12330,'xj97145116',56778287 union all select 12329,'xj54634388',37403046 union all select 12328,'xj20628465',89361545 union all select 12327,'xj77216647',61986394 union all select 12326,'xj50832486',28574566 union all select 12325,'xj32550567',91282638 union all select 12324,'xj17127224',67759395 union all select 12323,'xj80835486',58577566 union all select 12322,'xj29148317',88781487 union all select 12321,'xj71816816',54775664 union all select 12320,'xj52632665',12364746 union all select 12319,'xj10129837',83989595 union all select 12318,'xj82835686',41577767 union all select 12317,'xj80625464',59357545 union all select 12316,'xj29831718',13691566 union all select 12315,'xj59134739',42814486 union all select 12314,'xj34139825',84762086 union all select 12313,'xj64343846',23075917 union all select 12312,'xj46151018',15693188 union all select 12311,'xj04546767',63288837 union all select 12310,'xj04346847',53988917 union all select 12309,'xj52834018',45604766 union all select 12308,'xj34559767',93282838 union all select 12307,'xj82147930',74817687 union all select 12306,'xj67132126',26775286select * from [TB]
if object_id('[TB]') is not null drop table [TB]
create table [TB]([col1] int,[col2] varchar(10),[col3] int)
insert [TB]
select 12334,'xj77334245',36066316 union all
select 12333,'xj35822317',28682165 union all
select 12332,'xj67832286',26574366 union all
select 12331,'xj15427944',74060125 union all
select 12330,'xj97145116',56778287 union all
select 12329,'xj54634388',37403046 union all
select 12328,'xj20628465',89361545 union all
select 12327,'xj77216647',61986394 union all
select 12326,'xj50832486',28574566 union all
select 12325,'xj32550567',91282638 union all
select 12324,'xj17127224',67759395 union all
select 12323,'xj80835486',58577566 union all
select 12322,'xj29148317',88781487 union all
select 12321,'xj71816816',54775664 union all
select 12320,'xj52632665',12364746 union all
select 12319,'xj10129837',83989595 union all
select 12318,'xj82835686',41577767 union all
select 12317,'xj80625464',59357545 union all
select 12316,'xj29831718',13691566 union all
select 12315,'xj59134739',42814486 union all
select 12314,'xj34139825',84762086 union all
select 12313,'xj64343846',23075917 union all
select 12312,'xj46151018',15693188 union all
select 12311,'xj04546767',63288837 union all
select 12310,'xj04346847',53988917 union all
select 12309,'xj52834018',45604766 union all
select 12308,'xj34559767',93282838 union all
select 12307,'xj82147930',74817687 union all
select 12306,'xj67132126',26775286select * from [TB]
/** 导入文本文件
EXEC master..xp_cmdshell 'bcp dbname..tablename in c:\DT.txt -c -Sservername -Usa -Ppassword'
//现有数据(1W条左右)的排列格式如下:
ID 卡号 密码
12330 xj97145116 56778287
12329 xj54634388 37403046
12328 xj20628465 89361545
12327 xj77216647 61986394
12326 xj50832486 28574566
12325 xj32550567 91282638
12324 xj17127224 67759395
12323 xj80835486 58577566//要导入的[Info]表结构如下:
[ID] [卡号] [密码] [等其他字段]//请问怎么让导入到这个[Info]表中
105 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 10 Average : (10500.00 rows per sec.) 下面是currency1.txt的部分内容 AED Emirati Dirham 1998-06-01 00:00:00.000
AFA Afghani 1998-06-01 00:00:00.000
... ... ...
... ... ...
ZWD Zimbabwe Dollar 1998-06-01 00:00:00.000 在使用密码登录时需要将-U后的用户名和-P后的密码加上双引号。 注:BCP除了可以在控制台执行外,还可以通过调用SQL Server的一个系统存储过程xp_cmdshell以SQL语句的方式运行BCP。如上述第一条命令可改写为 EXEC master..xp_cmdshell 'BCP AdventureWorks.sales.currency out c:\currency1.txt -c -U"sa" -P"password"'
执行xp_cmdshell后,返回信息以表的形式输出。为了可以方便地在SQL中执行BCP,下面的命令都使用xp_cmdshell执行BCP命令。
(
col1 nvarchar(20),
col2 nvarchar(20),
col3 nvarchar(20)
)go
-- bulk insert 以用户指定的格式复制一个数据文件至数据库表或视图中
bulk insert tab1 from "C:\abc.txt"
/*
----abc.txt文件中存放了数据
12334 xj77334245 36066316
12333 xj35822317 28682165
12332 xj67832286 26574366
12331 xj15427944 74060125
12330 xj97145116 56778287
12329 xj54634388 37403046
12328 xj20628465 89361545
12327 xj77216647 61986394
12326 xj50832486 28574566
12325 xj32550567 91282638
12324 xj17127224 67759395
*/