我需要一个可以读取包含以下内容的文件的 SP
ÿ 43223233ÿÌÿÿjiihç 1Ý30BRÿ 43223223ÿÌÿÿjiihæ 1Ý30BRÿ 4ÿÌÿÿjiihå 1Ý30BRÿ 4ÿÌÿÿjiihä 1Ý30BRÿ 43213-23ÿÌÿÿjiihã 1Ý30BRÿ 43223223ÿÌÿÿjiihâ 1Ý30BRÿ 40) ÿÌÿÿjiiiá 1Ý30BRÿ 4ÿÌÿÿjiiià 1Ý30BRÿ 4$$"#"#3ÿÌÿÿjiihß 1Ý30BRÿ 43223223ÿÌÿÿjiihÞ 1Ý30BRÿ 43223233ÿÌÿÿjiihÝ 1Ý30BRÿ 4ÿÌÿÿjiihÜ 1Ý30BRÿ
到 SQL Server 中的单个列中。所需的输出是
ÿ 43223233ÿÌÿÿjiihç 1Ý30BR
ÿ 43223223ÿÌÿÿjiihæ 1Ý30BR
ÿ 43223223ÿÌÿÿjiihæ 1Ý30BR
ÿ 43223223ÿÌÿÿjiihæ 1Ý30BR
从那里开始,每一行必须被转换成一个实际可读值的数组
这在 SQL 中甚至可能吗?我从哪说起呢??我已经尝试过 BCP 等,但我看不到它的运行。
然而,我创建了一个 VB 应用程序,它完全符合我的需要,这里是代码
Open "c:\binaryfile.dat" For Binary As #1
Open "c:\converted.npw" For Output As #2
Do While Not EOF(1)
For j = 0 To 31
Get #1, , InputInfo
Write #2, InputInfo
Next
Write #2, Chr(10)
Loop
Close
Open "c:\converted.npw" For Input As #1
Open "c:\finishedproduct.csv" For Output As #3
Do While Not EOF(1)
Input #1, Discrete, Spare, ExAn8, ExAn7, ExAn6, ExAn5, ExAn4, ExAn3, ExAn2, ExAn1, InAn8, InAn7, InAn6, InAn5, InAn4, InAn3, InAn2, InAn1, MsgCount, OpMessage, TimeMilliseconds, TimeSecs, TimeMins, TimeHours, TimeMonths, TimeDays, TimeYear2, TimeYear1, Serial4, Serial3, Serial2, Serial1, NewLineChar
strSerial = Chr(Serial1) & Chr(Serial2) & Chr(Serial3) & Chr(Serial4)
strDate = TimeDays & "/" & TimeMonths & "/" & TimeYear
strTime = CInt(TimeHours) & ":" & CInt(TimeMins) & ":" & CInt(TimeSecs)
If strDate <> "" And IsDate(strDate) And IsDate(strTime) Then
Write #3, strSerial; strDate; Format(strTime, "HH:mm:ss"); OpMessage; MsgCount; InAn1; InAn2; InAn3; InAn4; InAn5; InAn6; InAn7; InAn8; ExAn1; ExAn2; ExAn3; ExAn4; ExAn5; ExAn6; ExAn7; ExAn8; Spare; Discrete
End If
Loop