alter table #_assetSelectionsTable# alter column assetSelectionKey varchar(25) not null insert into #_assetSelectionsTable# ( assetSelectionKey, fileId ) select cast(concat('DOC',':',docId) as varchar) as assetSelectionKey, docId as fileId from tbl_DOC_Documents with (nolock) where docId = and ownerId = and fsl_tablecode = select * from #_assetSelectionsTable# where assetSelectionKey = insert into #_assetSelectionsTable# ( assetSelectionKey, fileId ) select cast(concat('IMG',':',imgId) as varchar) as assetSelectionKey, imgId as fileId from tbl_IMG_Images with (nolock) where imgId = and ownerId = and fsl_tablecode = insert into #_assetSelectionsTable# ( assetSelectionKey, fileId ) select cast(concat('#_contentDomain#',':',fileId) as varchar) as assetSelectionKey, fileId from #_repositoryTable# with (nolock) where fileId = and ownerId = and ownerType = delete from #_assetSelectionsTable# where assetSelectionKey = delete from #_assetSelectionsTable#