Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2006
    Posts
    28

    Unanswered: howto add more column into select record?

    hi, good day,

    i have try following to get the records of the existing folder using :

    Code:
    insert into my_table
    exec xp_dirtree 'c:\temp'
    for example , it give the result

    subdirectory depth
    --------------------
    another 1
    TEST 1
    txtfiles 1
    anotherSub 2



    my question is , can i have add another column maindirectory into this existing result ?
    and my expected result would like to be as follow

    main directory subdirectory depth
    --------------------------------------

    another another 1
    TEST TEST 1
    txtfiles txtfiles 1
    TEST anotherSub 2


    is it possible ? thanks for guidance

  2. #2
    Join Date
    Jul 2002
    Posts
    229
    You could maybe do

    insert into my_table
    EXEC master..xp_cmdshell 'tree /a'

    and write a SP that parses the data.

  3. #3
    Join Date
    Jul 2006
    Posts
    28
    hi, coolberg, when run

    Code:
     
    insert into my_table
    exec xp_dirtree 'c:\temp'
    it give only 2 columns as result, that are subdirectory and depth , i still can't get you how to insert more column into "my_table" for your sample ,thanks for guidance

  4. #4
    Join Date
    Jul 2002
    Posts
    229
    You'll have to write some program code, like a SP. The INSERT I wrote just stores the input data to that SP.

  5. #5
    Join Date
    Jul 2006
    Posts
    28
    do u mind to show me sample code , coolberg ? thank for helping

  6. #6
    Join Date
    Jul 2002
    Posts
    229
    I was just thinking loudly, I've never written any code.

Posting Permissions

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