Results 1 to 3 of 3

Thread: DTS - Help !

  1. #1
    Join Date
    Jun 2002
    Location
    Singapore
    Posts
    71

    Unanswered: DTS - Help !

    Hello All.

    For some special reasons, my table is created every week with a new week no. Please see attached file or screen shot for details.

    I would like to output the content of this table to a .csv file via DTS package but I can't do it because the field name (week) of the table increases every week or changes every new month. In DTS, each field in the table and output field is fixed.

    Please advise is there a way round for this. Or beside using DTS package, is there other methods to output the content. I can't change the table structure now.

    Thank you in advance for your advise.

    Best regards
    Attached Thumbnails Attached Thumbnails Weeks.JPG  

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Within DTS, you can declare a global variable for the file name or table name. You can then include code in your DTS package to determine the appropriate value at runtime.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jun 2002
    Location
    Singapore
    Posts
    71
    Hello Blindman.

    Thank you for your advise. After reading the documentation on global variable, I find them difficult to understand.

    I have used below instead to output my sql table instead and it works perfect. Once again, thank you.


    declare @output varchar(5000)

    SELECT @output = 'bcp <DB Name>.dbo.<Table Name> out D:\<FileName.csv> -t "," /S<ServerName> /U<ID> /P<Password> /c '

    EXEC master..xp_cmdshell @output

Posting Permissions

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