SunQuest
           Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 22nd, 2006, 09:28 AM
tvks tvks is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hyderabad, AP, India
Posts: 49 tvks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 55 m 43 sec
Reputation Power: 2
SQL Server 2005 in PHP

Hi,

I have to use front end php and backend SQL Server 2005. I need to fetch data from a table in SQL Server 2005 database and create a Excel file. The table has more than 65000 records. I use the following code.

php Code:
Original - php Code
  1.  
  2. <?
  3. $sqlconnect=mssql_connect("host","user","password");
  4. $sqldb=mssql_select_db("dbase_name",$sqlconnect);
  5. $sqlquery="select * from master_table;";
  6. $results= mssql_query($sqlquery);
  7.  
  8. $out = "";
  9.  
  10. while ($field = mssql_fetch_field($results)){
  11. $out .= '"'.$field->name.'",';
  12. }
  13. $out .="n";
  14.  
  15. while ($row = mssql_fetch_assoc($results)){
  16. foreach ($row as $col=>$val){
  17. $out .= '"'.$val.'",';
  18. } 
  19. $out .="n";
  20. }
  21. mssql_close($sqlconnect);
  22. $f = fopen ('export.csv','w');
  23. fputs($f, $out);
  24. fclose($f);
  25.  
  26. header('location:export.csv');
  27.  
  28. ?>


But, this code is too slow. It takes hours and no result. It works fine for a very small table. How else do I go about converting a very big table in SQl Server 2005 to Excel (.xls or .csv).

Any better code would be applaudable.

Thanx in advance.

Regards,

tvks

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > SQL Server 2005 in PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway