Results 1 to 4 of 4

Thread: How to append contents of files?

  1. #1
    Join Date
    Nov 2004
    Posts
    66

    How to append contents of files?

    I have two files containing the SQL statements to drop and create two stored procedures, "StoredProcedure1.sql" and "StoredProcedure2.sql".

    It is possible to (1) create a new file (2) take the contents of both files and append the contents of both files into this new file using T-SQL?

  2. #2
    Join Date
    Aug 2006
    Posts
    57
    Not without resorting to such hacks as xp_cmdshell.

    I would use your favorite scripting language (python, dos, javascript, vbscript, whatever) to do this.

  3. #3
    Join Date
    Nov 2004
    Posts
    66

    Whatever is available in T-SQL

    I've tried looking at xp_cmdshell, but I can't seem to find a solution even with xp_cmdshell.

  4. #4
    Join Date
    Aug 2006
    Posts
    57
    with xp_cmdshell, you can do *anything*. that's why you shouldn't use it :}

    if you must know, however, you can use this DOS command in windows to concatenate two files to a third file:

    copy file1.txt+file2.txt file3.txt

    so you would just pass this to xp_cmdshell to do what you are asking.
    Last edited by jezemine; 10-11-2006 at 11:06 AM.

Posting Permissions

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