SQL DTS LOOP PRocess to select and export Top n rows from SQL Table

  • Hi Guys,

    I love this Forum really good especially for a Learner like me.

    This is important and I need a quick solution. Pls note I am working on SQL Server 2000.

    I have a SQL table with 2M rows which we are migrating to SAP system but due to limitation in SAP which accepts text files with only 9999 rows.

    So I want an automated process which will loop through a SQL table pick the Top 9999 and dump it on a text file in a network and then loop the table again to pick the next 9999 and so on until the source exhaust.

    I have created a DTS Package to assist in this where created a transformation with source and destination (text file) but I am having issues in looping this process. Do i need a VB script to do this? Any one one please suggest?

    my query is:

    Select top 9999 Lotnumber, AutoNum, Itemnumber

    from dbo.MigrationGas

    where Status is null

    Order by AutoNum

    Then do an Update query with Status = 1 for the one already selected but what should be my query:

    Thanks in Advance

    Arun

  • You say you are using SQL 2000, but this is in the SQL 2005 forum, so you have a copy of SSIS avalaible?

    if so, this could be acheived by using a for-each container, you could create a lookup table that contains the the row numbers that you want to split on, then use the for-each to loop through this and run a dataflow that creates a flat-file with the name based upon the rownumbers.

    If you do not have 2k5 and SSIS, then i am not sure if this is possible with DTS as i have not used that for years..

  • If 2000 check out http://www.sqldts.com



    Shamless self promotion - read my blog http://sirsql.net

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply