34,697
社区成员
发帖
与我相关
我的任务
分享
--fmt 文件
9.0
3
1 SQLCHAR 0 10 "," 1 字段1 ""
2 SQLCHAR 0 10 "," 2 字段2 ""
3 SQLCHAR 0 10 "\r\n" 3 字段3 ""
--fmt 文件
9.0
3
1 SQLCHAR 0 10 "\t" 1 字段1 ""
2 SQLCHAR 0 10 "\t" 2 字段2 ""
3 SQLCHAR 0 10 "\r\n" 3 字段3 ""
create proc sp_bulk (@dt char(8))
as
BEGIN
declare @varA varchar(100)
declare @varB varchar(100)
declare @varC varchar(100)
set @varA='D:\A'+@dt+'.TXT'
set @varB='D:\B'+@dt+'.TXT'
set @varC='D:\C'+@dt+'.TXT'
PRINT('
insert table表(字段1, 字段2, 字段3,日期)
SELECT LTRIM(字段1),LTRIM(字段2),LTRIM(字段3),'''+@dt+'''
FROM OPENROWSET ( BULK '''+@varA+''',
FORMATFILE = ''D:\txt.fmt'',firstrow=2) AS a')
PRINT('
insert table表(字段1, 字段2, 字段3,日期)
SELECT LTRIM(字段1),LTRIM(字段2),LTRIM(字段3),'''+@dt+'''
FROM OPENROWSET ( BULK '''+@varB+''',
FORMATFILE = ''D:\txt.fmt'',firstrow=2) AS a')
PRINT('
insert table表(字段1, 字段2, 字段3,日期)
SELECT LTRIM(字段1),LTRIM(字段2),LTRIM(字段3),'''+@dt+'''
FROM OPENROWSET ( BULK '''+@varC+''',
FORMATFILE = ''D:\txt.fmt'',firstrow=2) AS a')
END