Using of #tables while designing the database is awesome experience....#tables are most useful when the space boundary databases......now i'l just explain how to get it....
SYNTAX:-
declare @idno as int,
@itemid as int,
@itemname varchar(50)
declare iteminfo cursor local for select * from ITEMLIST
OPEN iteminfo
FETCH NEXT FROM iteminfo INTO @ITEMID, @ITEMNAME
while @@FETCH_STATUS=0
begin
set @idno=(select idno from itemid_list where itemid=@itemid)
create table #Itemmaster (idno int, itemid int, itemname varchar(100))
insert into #itemmaster values (@idno, @itemid, @itemname)
FETCH NEXT FROM iteminfo INTO @ITEMID, @ITEMNAME
end
close iteminfo
deallocate iteminfo
---------------to see the data in #table-------------
select * from #itemmaster
Note:- Before using this code , u must created itemlist and itemid_list tables.then enjoy the programming...........