// Selection of image data in the multimedia table
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest,'products_image_small' sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (SGROUP = 'products_image' )
union
// Selection of image data in the multimedia table
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest,sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (SGROUP = 'products_image' )
union
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest, sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (  SGROUP = 'products_subimage1' )

union
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest, sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and ( SGROUP = 'products_subimage2')

union
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest, sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage3' )

union
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest, sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage4' )

union
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest,  sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage5' )
union
Select substring(SPATH {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 200) Path , sorgfilename dest,  sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage6' )