Paul McCartney: lead vocals, guitar, bass, piano, hammond organ, drums, timpani, percussion, recorder, flugelhornКак создать представление уникальных элементов из списков?
Mal Evans: backing vocals (2, 6), saxophone (23)
CREATE VIEW RoleDivided
AS
SELECT DISTINCT TRIM( value ) AS RoleSingle
FROM AlbumRole
CROSS APPLY STRING_SPLIT( dbo.RoleDelTrack( [Role] ), ',' )
CREATE FUNCTION dbo.RoleDelTrack ( @RL VARCHAR(500) ) RETURNS VARCHAR(500)
WITH EXECUTE AS CALLER
AS
BEGIN
WHILE (CHARINDEX( '(', @RL) > 0 ) BEGIN
SET @RL = TRIM( LEFT( @RL, CHARINDEX( '(', @RL) - 1 ))
+ RIGHT( @RL, LEN( @RL ) - CHARINDEX( ')', @RL ))
END
RETURN @RL
END