我有8k产品代码的MS Excel文件。例如:
SOR 309704 or
LEW 2992 6005BK
我需要一个将此字符串剪切到第一个空格的公式。
SOR 309704 to 309704
LEW 2992 6005BK to 2992 6005BK
你能帮我解决这个问题吗?
亲切的问候
答案 0 :(得分:2)
DECLARE @T TABLE (ARIDNR INT, LIEFNR varchar(5)) --table variable for loading sample data
INSERT INTO @T (ARIDNR, LIEFNR) VALUES (1,'A'),(2,'A'),(3,'A'),(1,'B'),(2,'B'); --add your sample data to it
WITH duplicates AS --the CTE portion to find the duplicates
(
SELECT ARIDNR FROM @T GROUP BY ARIDNR HAVING COUNT(*) > 1
)
SELECT t.* FROM @T t --shows results from main table
INNER JOIN duplicates d on t.ARIDNR = d.ARIDNR --where the main table can be joined to the duplicates CTE
将为您提供第一个空格角色的位置。然后,您可以使用=FIND(" ",A1)
函数在右侧获取所有内容:
right()