0

This may sound like a bizarre question, so let me clarify.

I am currently exporting a bunch of lines from a MS SQL database to a file. The total is approximately 5M records with 10 fields.

Result file is huge and target software struggles to handle it.

What I'd like to do is I'd like to split this request in order to get multiple smaller files instead of one huge file, grouped with one of the 10 fields, let's say by regions.

Is that something SQL Studio can do ? Otherwise is there any solution to my problem ?

I have never worked with SQL fuctions, mabe could they help as well ?

Thanks in advance for your help & have a great day ! Vincent

jarlh
  • 42,561
  • 8
  • 45
  • 63
Vincent Monteil
  • 568
  • 5
  • 22

1 Answers1

1

You can handle this by SQL but I would say if you already produced your intended file and only need to split it you can split the file using some tool. See this question for how to do it on Windows using command line: Batch file to split .csv file

If it is a csv file as seems from the tags of this question, you will have to copy the first line and add to all files but first one. Because first line is the header of the CSV file and I assume your application you will need it for every part file.

The other solution would be to write a SQL statement to filter results. Say if you want to filter by regions field you can write: SELECT * FROM WHERE regions = ''

This however is very simplistic and you might need to do more work to get intended result. Your regions values might not be the same number as your intended parts. You will need to figure out how to split based on many region values. You can also implement some SQL partitioning of the result set but I would say the file processing solution should be easier for you to apply.

Mohammad
  • 1,930
  • 1
  • 21
  • 31