SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Table with dynamic name caused loading slow
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

micnie_2020
Posting Yak Master

Malaysia
226 Posts

Posted - 11/30/2012 :  05:35:18  Show Profile  Reply with Quote
Hi All,

I have 2 SP:-

1. Use a lot of

set @sSQL=@sSQL+' from tbl'+@username+' '
OPEN contact_cursor;
FETCH NEXT FROM contact_cursor

Time Taking for same sql statement when print @sSQL: 2:50:45

2. ... from tbl
OPEN contact_cursor;
FETCH NEXT FROM contact_cursor

Time Taking for same sql statement when print @sSQL: 00:50:45


May i know how can i perform all the table with dynamic name with faster speed? Coz all the table involved calculation & insert into the table created based on username.

Thank you.

Regards,
Micheale

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 11/30/2012 :  05:43:28  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
What is the time for - the duration of the processing? i.e. from cursor open to close?

Try inserting into a temp table.
Then you can loop through the temp table (could use a cursor but no need).

I'm guessing the dynamic sql has an effect on the cursor processing - doing this will make the processing local to the statement and also make it easy to see whether it is the extract of the data that is the issue or the processing.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000