declare @o int
declare @c int
declare @delim varchar(200)


set @delim = '++++++++++++++++++++++++++++++++++++++++'

declare gd1 cursor local for
select id from TABLE_1 where

open gd1
fetch next from gd1 into @o

while @@FETCH_STATUS = 0
begin
   
    print @delim
    print @o
   
    declare gd2 cursor local for
    select id from TABLE_2 where table1_id = @o
   
    open gd2
    fetch next from gd2 into @c
    while (@@FETCH_STATUS = 0)
    begin
        print '--->' + convert(varchar , @c)
        fetch next from gd2 into @c
    end
   
    close gd2    
    deallocate gd2
   
    fetch next from gd1 into @o
end

close gd1
deallocate gd1


Tags
Comments
10.10.2011
brilliant!
Leave a trace
Name *
Email *
Website
Anti SPAM * Code (8 + 1) =
Leave me a comment *
 
All comments are subject to editorial review
Post being viewed right now
Item date: 04.02.2009
Views: 1275
Item date: 05.02.2009
Views: 913
Item date: 15.05.2009
Views: 1301
Item date: 10.04.2009
Views: 1915
Item date: 13.05.2009
Views: 1571
Item date: 16.06.2009
Views: 456
Item date: 19.07.2009
Views: 1233
Item date: 01.05.2008
Views: 1771
Item date: 02.12.2011
Views: 168
Item date: 13.05.2009
Views: 1834