Home Forums SQL Server 2008 T-SQL (SS2K8) how to show single column value (separated by ;) as multiple columns otherwise null RE: how to show single column value (separated by ;) as multiple columns otherwise null

  • Took a shot at it...

    SELECT

    PARSENAME(REPLACE([Subject],';','.'),1) AS Subject1,

    PARSENAME(REPLACE([Subject],';','.'),2) AS Subject2,

    PARSENAME(REPLACE([Subject],';','.'),3) AS Subject3

    FROM YourTable

    Works with your sample data and the assumption that 3 subjects is all you'll need. If the number of subjects changes, tweaking will be necessary, but this should do for the moment.

    EDIT: Gah, that's what I get for being interrupted while I'm thinking :hehe:. This reverses the order of the original input. One moment while I correct that...

    - 😀