• I can't believe this is the slickest way to achieve what you're after, but this works :w00t:

    [font="Arial Black"]CREATE PROCEDURE EXPORT_DATA

    @FileName varchar(255)

    as

    begin

    declare @bcpCommand varchar(255), @Result int

    set @bcpCommand = 'bcp "Select 1 as a" queryout "' + @FileName + '" -c -t, -T -S '

    exec @Result = master..xp_cmdshell @bcpCommand, no_output

    end[/font]

    Don't forget that xp_cmdshell is not enabled in the db configuration by default

    Mike.