Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含大量行的表。我想选择一个特定列的所有值并为每个唯一值创建单独的列。
例如 :
变成这样的东西:
SELECT left_side = RTRIM(SUBSTRING(col, 1, CHARINDEX('->', col)-2)), right_side = LTRIM(SUBSTRING(col, CHARINDEX('->', col) + 2, 4000)) FROM dbo.table;
嗨,您可以使用内置函数 Left、Right 或 CHARINDEX 等。
希望这个例子能有所帮助
示例一
示例二
谢谢