Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256

    Unanswered: Building text files

    Ok, I have an sp that'll build an SAP feed based on parameter input (params control which type of file I want to create). I want to build 9 files in total.

    I have a table set up with my parameters and output file names.

    Question 1: Process from DTS
    I have a DTS package which will build a file based on params and filename from table, pulled with a Dynamic Properties task. How can I iterate through my table of parmas to create the muliple files?

    Question 2: Process from a stored proc
    I have a stored proc, from which the interation through values is simple. How can I create and export to the text files from the stored proc? I think I may be having a mental fart on this one. I could create a text linked server dynamically, but I have not played with them much, How to I write to one (create table etc).

    PS: The file data cannot include cilumn headings

    TIA -
    bpd
    -bpd

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I'd go with the sproc and bcp out

    Just change the IN to OUT

    Code:
    		SET @cmd = 'bcp ' + @db_name + '..ETRS_ASI_FED_TEMP in ' 
    			+ @FilePathAndName + ' -t"\t" -c -S' + @@servername + ' -Uscrub -Pscrub'
    
    		SET @Command_string = 'EXEC master..xp_cmdshell ''' + @cmd + ''''
    
    		Select @Command_String
    
    		Exec(@Command_String)
    Last edited by Brett Kaiser; 01-12-04 at 18:02.
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Given this problem, I would probably try a VB or PERL script to extract the data. I know how to call bcp from PERL, but VB is still a bit new to me. Fortunately, if the data set you are exporting is small (few thousand rows), you could get away with just using FileObject writes. Biggest problem I have had with bcp is remembering to check the error file for any problems. Again, easy for me in PERL, but VB....

  4. #4
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    Thanks! bcp is what I was looking for. Glad I can avoid DTS all together.

    -bpd
    -bpd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •