Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to reduce number of table generate by procedur
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

132 Posts

Posted - 02/22/2013 :  15:28:07  Show Profile  Reply with Quote
Hello All,

Could you please help me out, i am in a wierd situation,

i have a sql store procedure (about 1350 lines in it), which quries data different tables and loads data to tables (about 11 tables)

the reason, the above procedure is generating 11 tables, i am using only 4 tables in these 11, but these 11 tables were derived internally data connected,

so the requirement is, after execute the procedure we want to generate only 4 tables(which i need, presently using) , i need to consolidate the proc to generate only 4 tables.

the reason why it is generating 11 tables is,

step1 load data to table, scrub and then apply some additionl logic then prepare table 2, then some update and union and insert to table 3 (using table 2 and table 1 and some other tables... etc it will go till 11 tables)

can i use temp tables ? here in proc to replace these 11 tables, so that i will have only required 3 tables in db remain all for temporary calculation, but temp tables shoun't visible after proc exec completes in db, or any other ideas please, does temp tables stay till proc execution completes or only valid for single sql statement ......

help me here, please assist me, guide me with all open ideas

pease thanks a ton

Posting Yak Master

132 Posts

Posted - 02/22/2013 :  15:44:35  Show Profile  Reply with Quote
any open ideas please....
Go to Top of Page

Bustaz Kool
Flowing Fount of Yak Knowledge

1834 Posts

Posted - 02/22/2013 :  18:05:11  Show Profile  Reply with Quote
Without some specifics about the tables and processing involved it is hard to come up with a specific solution. Having said that, it sounds like temp tables might be of use here. If your processing tries to populate four (three?) permanent tables then the other tables could be temp tables. The temp tables live within the context of a batch. If they are created within your stored procedure, they would be available as long as your procedure is still executing but would automatically be destoyed when the procedure returns to the caller.

There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000