现在有一个数据库haha的表0727number date time
123 20100701 12:00:00
223 20100701 14:00:00
现在有一个test.txt文本文件。里面内容是
12320100701120000
43220100701120000
45620100701120000
87620100701120000
如何将txt文件导入数据表中EXEC master..xp_cmdshell 'bcp haha.dbo.0727 in C:\test.txt -c -U"sa" -P"pwd" -t"|"'
上面语句错了~
问题:
如何讲txt文本内容导入三个字段里面
123 20100701 12:00:00
223 20100701 14:00:00
现在有一个test.txt文本文件。里面内容是
12320100701120000
43220100701120000
45620100701120000
87620100701120000
如何将txt文件导入数据表中EXEC master..xp_cmdshell 'bcp haha.dbo.0727 in C:\test.txt -c -U"sa" -P"pwd" -t"|"'
上面语句错了~
问题:
如何讲txt文本内容导入三个字段里面
goBULK
INSERT #t
FROM 'd:\test.txt'
WITH (
FIELDTERMINATOR = ' ',
ROWTERMINATOR = '\n'
)
goinsert 数据库表
select left(col,3),substring(col,4,8),stuff(stuff(right(col,6),3,0,':'),6,0,':') from #t
godrop table #t