T-SQL?????????????????
???????????? ???????[ 2013/1/23 10:03:00 ] ????????
??????????У???????????????????????????????????????????????????????е?????????????????????????????????????????????????????д???λ????
?????????
??????????????????滯???????????????????????????????????????α?????????????????????????ɡ?
?????????????Щ??????????·?????SUBSTRING????????????????????CHARINDEX??????λ???????????????????
????????2005??????????CTE???????????????????????????????????????????????????????TABLE????????
?????????????
????????????4???????????
????????????????????????????????BULKINSERT ????BCP???????????INSERT??????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????
????????????????????4??????????
USEtempdb
GO
????--?????????洢???????
CREATE TABLE Arrays
(
salesID VARCHAR(10) NOT NULL ??
salesOrd VARCHAR(8000) NOT NULL
)
GO
????--???????insert ????ж??????????????
INSERT INTO Arrays
VALUES ( 'A'?? '20?? 223?? 2544' ) ;
INSERT INTO Arrays
VALUES ( 'B'?? '30?? 23433?? 28' ) ;
INSERT INTO Arrays
VALUES ( 'C'?? '12?? 10' ) ;
INSERT INTO Arrays
VALUES ( 'D'?? '4?? 6?? 45678?? 2' ) ;
GO
????--???????????洢??????????????
CREATE TABLE Nums
(
c1 INT NOT NULL
PRIMARY KEY
) ;
GO
????--????????
DECLARE @i INT
SET @i = 1
WHILE @i <= 8000
BEGIN
INSERT INTO Nums
VALUES ( @i )
SET @i = @i + 1
END
????--??????????2005????汾??á????ROW_NUBMER????
SELECT salesID [?????] ??
ROW_NUMBER() OVER ( PARTITION BY salesID ORDER BY c1 ) AS [???] ??
SUBSTRING(salesOrd?? c1?? CHARINDEX('?? '?? salesOrd + '?? '?? c1) - c1) AS [?]
FROM Arrays
JOIN Nums ON c1 <= LEN(salesOrd)
ANDSUBSTRING('?? ' + salesOrd?? c1?? 1) = '?? '
ORDER BY salesID ??
[???]
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11