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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Starting at a certain member id

Author  Topic 

xrum
Yak Posting Veteran

87 Posts

Posted - 2010-02-17 : 14:58:36
hi,

i have a table with over 6K records,i'm trying to extract them to excel, but it seems like its too much data, and i go into timeout mode.

what i'm trying to do is:

read the first 2k records - export to excel
then start with the next 2k, etc.

I'm not really sure where to begin on this.

1. I count the number of records.
2. if the number i get is less then 2k then i just read them as is (this is working)
3. if the number is larger then 2k then i need to read the first 2k, and then start reading the second part, starting with 2001 (this is where i'm stuck)

how do i tell it to start giving me records starting with number 2001? or 4001? etc?

Thanks!

X002548
Not Just a Number

15586 Posts

Posted - 2010-02-17 : 15:35:29
Do yuo know what bcp is?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-17 : 16:29:38
How do you make your export to excel?
6k records is like nothing in sql server.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-02-17 : 18:12:28
Do all 6k rows at once with bcp (command line tool):
bcp.exe db1.dbo.t1 out C:\SomeFile.csv -t, -T -c -r\r\n -SsomeServer\someInstance

Alternatively you can use SSIS or DTS. I prefer bcp for a simple export like yours. It'll complete in just a couple of seconds, so no timeout issue at all.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-18 : 00:52:14
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2010-02-18 : 08:03:32
If your server is 64 bit, and if you are using openrowset commands like in the examples in the link Vishakh gave, you may run into problems. I don't recall whether it was timeout or whether it just fails with an error message. The failure has to do with Jet drivers not being available for 64-bit servers.

If you are trying to fill an Excel sheet from an Excel macro, lookup http://support.microsoft.com/kb/306125
Go to Top of Page
   

- Advertisement -