【发布时间】:2016-01-30 01:22:50
【问题描述】:
我有一个固定文件,我将其导入到一个列中,其中的数据类似于您在下面看到的:
ABC$ WC 11683
11608000163118430001002010056788000000007680031722800315723
11683000486080280000002010043213000000007120012669100126691
ABC$ WC 000000020000000148000
ABC$ WC 11683
1168101057561604000050200001234000000027020023194001231940
54322010240519720000502000011682000000035640006721001067210
1167701030336257000050200008765000000023610029066101151149
11680010471244820000502000011680000000027515026398201263982
我想将此数据拆分并插入到另一个表中,但只要“11683”等于另一个表中的列值 + 1,我就想这样做。然后我将增加该值(这里看不到)。
我尝试了以下方法:
declare @blob as varchar(5)
declare @Num as varchar(5)
set @blob = substring(sdg_winn_blob.blob, 23,5)
set @Num = (Cnum.num + 1)
IF @blob = @Num
INSERT INTO SDG_CWF
(
GAME,SERIAL,WINNER,TYPE
)
SELECT convert(numeric, substring(blob,28, 5)),convert(numeric, substring(blob, 8, 9)),
(Case when (substring(blob, 6,2)='10') then '3'
when (substring(blob, 6,2)='11') then '4'
else substring(blob, 7, 1)
End),
(Case when (substring(blob, 52,2)='10') then '3'
when (substring(blob, 52,2)='11') then '4'
else substring(blob, 53, 1)
End)
FROM sdg_winn_blob
WHERE blob not like 'ABC$%'
else
print 'The Job Failed'
插入工作正常,直到我尝试检查位置 (23, 5) 处的数字是否与 Cnum 表中的数字相同。我得到错误:
Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "sdg_winn_blob.blob" could not be bound.
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "Cnum.num" could not be bound.
【问题讨论】:
-
您是否尝试过包含架构 dbo.Cnum.num & dbo.sdg_winn_blob.blob
标签: tsql sql-server-2005