Sorting a View or "bcp out" file.

Sorting a View or "bcp out" file.

Post by Jeff Zeldin » Fri, 04 Jun 1999 04:00:00

I've got a view with a half-million rows in it.  The view is a result of
a table join between two tables, each of a half-million rows.

We are using this to generate a pipe-delimited flatfile, by using bcp to
generate the file.   Speed of generation is of the essence, as this is a
time critical batch process.

I need to do two things:

1. Apply a "where" type clause to the bcp to selectively generate
multiple files from the data
2. sort the data in the output file, using bcp (unless there's a better

I've already tried to apply a sort to the view, but Sybase doesn't let
you do that.    And I have no idea how to apply where clauses or sorting
to a bcp out.

Any help would be appreciated.




D&IS Manager             Phone: (416) 979-0050 x2006
Image Impression Inc.    Web:


1. bcp text file with "" identifiers

I'm trying to use bcp to copy a comma delimited text file with ""
identifiers.  My problem is this.

The instance of sqlserver is on my D: drive and the database is on my
G: drive.  This is what I have:

d:\MSSQL$MYINSTANCE>bcp g:\mydata\MyDB..MyTable in a:\Mytextfile.txt
-n -t"," -m50 -hTABLOCK -T

I'm getting "Cannot open database requested in login 'g:\mydata\MyDB'.
Login fails.

I've tried using "-SMyServer/MSSQL$MYINSTANCE" with this but come up
with "Server cannot be found.

Any suggestions will be GREATLY appreciated.  The text file has over 1
million records and this is the only way I know of uploading it to

Thanks in advance.

2. Database Use or Table Use

3. max of ("...","...","..")


5. Why is "SORT by DESC" slower than "SORT BY ASC"

6. List of research institutes WANTED

7. how can I make numbers sort so "100" sorts after "20"

8. Question: Stored Procedure Problem

9. sa CAN "xp_cmdshell bcp blabla", other users cannot

10. BCP "HOW-TO"?

11. BCP - text qualifiers ""

12. "function sequence error" with BCP

13. problem with the command "bcp"