我已经在电子表格中给出了一些数据,这些数据很快将进入自动导入,因此我无法在电子表格中执行任何手动输入。数据基本上有以下几列。 Trayid,托盘名称,itemdescription和rownumber。我自己没有建立这些表或我会建立它不同,但我必须坚持已经设置的格式。根据SQL Server 2012中的rownumber更新行
正在导入的数据将在后面进行介绍。
Trayid | Trayname | ItemDescription | RowNumber
1 Tray 1 Product 1 1
Product 2 2
Product 3 3
Product 4 4
2 Tray 2 Product 1 1
Product 2 2
Product 3 3
Product 4 4
Product 5 5
什么,我需要做的是更新每个以下第1行的其他行的trayid和trayname,因此,例如它会看起来像。
Trayid | Trayname | ItemDescription | RowNumber
1 Tray 1 Product 1 1
1 Tray 1 Product 2 2
1 Tray 1 Product 3 3
1 Tray 1 Product 4 4
2 Tray 2 Product 1 1
2 Tray 2 Product 2 2
2 Tray 2 Product 3 3
2 Tray 2 Product 4 4
2 Tray 2 Product 5 5
即时猜测我需要使用光标或东西,但林不知道,我想它可以通过下降的rownumbers,当它看到的ROWNUMBER 1停止再次,然后下一个trayid继承和完成trayname。
对不起,如果我需要没有意义,它是尴尬的解释。