• MyDoggieJessie (1/22/2013)


    Crude, but this will work, just loop through a directory (if you are able to execute xp_cmdshell, if not I'm sure there's a powershell script lingering around)DECLARE

    @Filepath varchar(75),

    @file varchar(25),

    @Cmd varchar(150)

    SET @file = 'test.csv'

    SET @filepath = 'C:\'

    SET @cmd = 'ren "' + @filepath + @file + '" "' + REPLACE(@file, 'csv', 'xls') + '"'

    PRINT @cmd

    EXEC xp_cmdshell @cmd, NO_OUTPUT

    Why would you want to do this via TSQL?

    This will only rename the files and not convert the CSV to XLS binary file.

    The question still remains why would you do it in SQL?

    I think it would work with SSIS. To read the CSV files in and then spit out as Excel.

    There are converters out in the net, just have to search for it.

    ---------------------------------------------------------------
    Mike Hahn - MCSomething someday:-)
    Right way to ask for help!!
    http://www.sqlservercentral.com/articles/Best+Practices/61537/
    I post so I can see my avatar :hehe:
    I want a personal webpage 😎
    I want to win the lotto 😀
    I want a gf like Tiffa :w00t: Oh wait I'm married!:-D