标签:des data har oledb order 写入 database object 文件
declare @XUHAO int,
@TM004 varchar(20),
@TD010 numeric(16,2),
@i int = 1 ,@x int
IF OBJECT_ID(‘tempdb..#TempA‘) IS NOT NULL DROP TABLE #TempA
select ROW_NUMBER() OVER (ORDER BY @XUHAO ASC) AS ID, * into #TempA from
OPENROWSET
(
‘Microsoft.Ace.OleDb.12.0‘
,‘Excel 12.0;DATABASE=C:\Users\Administrator\Desktop\产品\301.xls‘
,‘SELECT * FROM [Sheet1$]‘
)
select @x = COUNT(*) from #TempA
print @x
while @i <= @x
begin
select @TM004 = 元件品号 from #TempA where ID = @i
if @TM004 is not null
begin
select TOP 1 @TD010 = TD010 from TOPLED2015..PURTD where TD018 = ‘Y‘ and TD004 = @TM004 ORDER BY substring(TD002,1,8) DESC
if @TD010 <> 0
begin
update
OPENROWSET
(
‘Microsoft.Ace.OleDb.12.0‘
,‘Excel 12.0;DATABASE=C:\Users\Administrator\Desktop\产品\301.xls‘
,‘SELECT * FROM [Sheet1$]‘
)
set 投料间距 = @TD010
where 元件品号 = @TM004
end
end
set @i = @i + 1
end
IF OBJECT_ID(‘tempdb..#TempA‘) IS NOT NULL DROP TABLE #TempA
标签:des data har oledb order 写入 database object 文件
原文地址:http://blog.51cto.com/gongxi/2131165