Hello all this is Part 2 to my other post of how to work with Variables.
I have two queries
first one:
then for every RF_PATH I need to join
so I need to loop through the first results adding the bottom column to the top.
Result being REL_NAME, RF_PATH, NEW_Column
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
I have two queries
first one:
Code:
select rel_name, RF_PATH
FROM RELEASES, RELEASE_FOLDERS
where REL_ID = rf_id
and (RF_PATH LIKE 'AAAAAUAABA%' OR RF_PATH LIKE 'AAAAAUAADA%')
then for every RF_PATH I need to join
Code:
declare @REL_NAME nvarchar(500)
declare @RF_PATH nvarchar(500)
set @RF_PATH = --The RF_PATH from the previous query - ex.'AAAAAUAAAAAIAAA'
set @REL_NAME = (Select RF_NAME from RELEASE_FOLDERS WHERE RF_PATH = LEFT(@RF_PATH,6)) + '>'
set @REL_NAME = @REL_NAME + (Select RF_NAME from RELEASE_FOLDERS WHERE RF_PATH = LEFT(@RF_PATH,9)) + '>'
set @REL_NAME = @REL_NAME + (Select RF_NAME from RELEASE_FOLDERS WHERE RF_PATH = LEFT(@RF_PATH,12)) + '>'
set @REL_NAME = @REL_NAME + (Select RF_NAME from RELEASE_FOLDERS WHERE RF_PATH = LEFT(@RF_PATH,15))
Select @REL_NAME
so I need to loop through the first results adding the bottom column to the top.
Result being REL_NAME, RF_PATH, NEW_Column
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008